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];} 390*54f1004bSSander Arens for (f = Nf; f < NfNew; ++f) {tmpd[f] = NULL, tmpdbd[f] = NULL; tmpi[f] = PETSC_TRUE; tmpa[f*2+0] = PETSC_FALSE; tmpa[f*2+1] = PETSC_TRUE;} 391a6cbbb48SMatthew G. Knepley ierr = PetscFree4(prob->disc, prob->discBd, prob->implicit, prob->adjacency);CHKERRQ(ierr); 3922764a2aaSMatthew G. Knepley prob->Nf = NfNew; 3932764a2aaSMatthew G. Knepley prob->disc = tmpd; 394a6cbbb48SMatthew G. Knepley prob->discBd = tmpdbd; 395249df284SMatthew G. Knepley prob->implicit = tmpi; 396a6cbbb48SMatthew G. Knepley prob->adjacency = tmpa; 397b7e05686SMatthew 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); 3982764a2aaSMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpobj[f] = prob->obj[f]; 3992764a2aaSMatthew G. Knepley for (f = 0; f < Nf*2; ++f) tmpf[f] = prob->f[f]; 4002764a2aaSMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpg[f] = prob->g[f]; 401475e0ac9SMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpgp[f] = prob->gp[f]; 4020c2f2876SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpr[f] = prob->r[f]; 4030c2f2876SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpctx[f] = prob->ctx[f]; 4042764a2aaSMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpobj[f] = NULL; 4052764a2aaSMatthew G. Knepley for (f = Nf*2; f < NfNew*2; ++f) tmpf[f] = NULL; 4062764a2aaSMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpg[f] = NULL; 407475e0ac9SMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgp[f] = NULL; 408b7e05686SMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgt[f] = NULL; 4090c2f2876SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpr[f] = NULL; 4100c2f2876SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpctx[f] = NULL; 411b7e05686SMatthew G. Knepley ierr = PetscFree7(prob->obj, prob->f, prob->g, prob->gp, prob->gt, prob->r, prob->ctx);CHKERRQ(ierr); 4122764a2aaSMatthew G. Knepley prob->obj = tmpobj; 4132764a2aaSMatthew G. Knepley prob->f = tmpf; 4142764a2aaSMatthew G. Knepley prob->g = tmpg; 415475e0ac9SMatthew G. Knepley prob->gp = tmpgp; 416b7e05686SMatthew G. Knepley prob->gt = tmpgt; 4170c2f2876SMatthew G. Knepley prob->r = tmpr; 4180c2f2876SMatthew G. Knepley prob->ctx = tmpctx; 4192764a2aaSMatthew G. Knepley ierr = PetscCalloc2(NfNew*2, &tmpfbd, NfNew*NfNew*4, &tmpgbd);CHKERRQ(ierr); 4202764a2aaSMatthew G. Knepley for (f = 0; f < Nf*2; ++f) tmpfbd[f] = prob->fBd[f]; 4212764a2aaSMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpgbd[f] = prob->gBd[f]; 4222764a2aaSMatthew G. Knepley for (f = Nf*2; f < NfNew*2; ++f) tmpfbd[f] = NULL; 4232764a2aaSMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgbd[f] = NULL; 4242764a2aaSMatthew G. Knepley ierr = PetscFree2(prob->fBd, prob->gBd);CHKERRQ(ierr); 4252764a2aaSMatthew G. Knepley prob->fBd = tmpfbd; 4262764a2aaSMatthew G. Knepley prob->gBd = tmpgbd; 4272764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4282764a2aaSMatthew G. Knepley } 4292764a2aaSMatthew G. Knepley 4302764a2aaSMatthew G. Knepley #undef __FUNCT__ 4312764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroy" 4322764a2aaSMatthew G. Knepley /*@ 4332764a2aaSMatthew G. Knepley PetscDSDestroy - Destroys a PetscDS object 4342764a2aaSMatthew G. Knepley 4352764a2aaSMatthew G. Knepley Collective on PetscDS 4362764a2aaSMatthew G. Knepley 4372764a2aaSMatthew G. Knepley Input Parameter: 4382764a2aaSMatthew G. Knepley . prob - the PetscDS object to destroy 4392764a2aaSMatthew G. Knepley 4402764a2aaSMatthew G. Knepley Level: developer 4412764a2aaSMatthew G. Knepley 4422764a2aaSMatthew G. Knepley .seealso PetscDSView() 4432764a2aaSMatthew G. Knepley @*/ 4442764a2aaSMatthew G. Knepley PetscErrorCode PetscDSDestroy(PetscDS *prob) 4452764a2aaSMatthew G. Knepley { 4462764a2aaSMatthew G. Knepley PetscInt f; 44758ebd649SToby Isaac DSBoundary next; 4482764a2aaSMatthew G. Knepley PetscErrorCode ierr; 4492764a2aaSMatthew G. Knepley 4502764a2aaSMatthew G. Knepley PetscFunctionBegin; 4512764a2aaSMatthew G. Knepley if (!*prob) PetscFunctionReturn(0); 4522764a2aaSMatthew G. Knepley PetscValidHeaderSpecific((*prob), PETSCDS_CLASSID, 1); 4532764a2aaSMatthew G. Knepley 4542764a2aaSMatthew G. Knepley if (--((PetscObject)(*prob))->refct > 0) {*prob = 0; PetscFunctionReturn(0);} 4552764a2aaSMatthew G. Knepley ((PetscObject) (*prob))->refct = 0; 4562764a2aaSMatthew G. Knepley ierr = PetscDSDestroyStructs_Static(*prob);CHKERRQ(ierr); 4572764a2aaSMatthew G. Knepley for (f = 0; f < (*prob)->Nf; ++f) { 4582764a2aaSMatthew G. Knepley ierr = PetscObjectDereference((*prob)->disc[f]);CHKERRQ(ierr); 4592764a2aaSMatthew G. Knepley ierr = PetscObjectDereference((*prob)->discBd[f]);CHKERRQ(ierr); 4602764a2aaSMatthew G. Knepley } 461a6cbbb48SMatthew G. Knepley ierr = PetscFree4((*prob)->disc, (*prob)->discBd, (*prob)->implicit, (*prob)->adjacency);CHKERRQ(ierr); 462b7e05686SMatthew G. Knepley ierr = PetscFree7((*prob)->obj,(*prob)->f,(*prob)->g,(*prob)->gp,(*prob)->gt,(*prob)->r,(*prob)->ctx);CHKERRQ(ierr); 4632764a2aaSMatthew G. Knepley ierr = PetscFree2((*prob)->fBd,(*prob)->gBd);CHKERRQ(ierr); 4642764a2aaSMatthew G. Knepley if ((*prob)->ops->destroy) {ierr = (*(*prob)->ops->destroy)(*prob);CHKERRQ(ierr);} 46558ebd649SToby Isaac next = (*prob)->boundary; 46658ebd649SToby Isaac while (next) { 46758ebd649SToby Isaac DSBoundary b = next; 46858ebd649SToby Isaac 46958ebd649SToby Isaac next = b->next; 47058ebd649SToby Isaac ierr = PetscFree(b->comps);CHKERRQ(ierr); 47158ebd649SToby Isaac ierr = PetscFree(b->ids);CHKERRQ(ierr); 47258ebd649SToby Isaac ierr = PetscFree(b->name);CHKERRQ(ierr); 47358ebd649SToby Isaac ierr = PetscFree(b->labelname);CHKERRQ(ierr); 47458ebd649SToby Isaac ierr = PetscFree(b);CHKERRQ(ierr); 47558ebd649SToby Isaac } 4762764a2aaSMatthew G. Knepley ierr = PetscHeaderDestroy(prob);CHKERRQ(ierr); 4772764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4782764a2aaSMatthew G. Knepley } 4792764a2aaSMatthew G. Knepley 4802764a2aaSMatthew G. Knepley #undef __FUNCT__ 4812764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSCreate" 4822764a2aaSMatthew G. Knepley /*@ 4832764a2aaSMatthew G. Knepley PetscDSCreate - Creates an empty PetscDS object. The type can then be set with PetscDSSetType(). 4842764a2aaSMatthew G. Knepley 4852764a2aaSMatthew G. Knepley Collective on MPI_Comm 4862764a2aaSMatthew G. Knepley 4872764a2aaSMatthew G. Knepley Input Parameter: 4882764a2aaSMatthew G. Knepley . comm - The communicator for the PetscDS object 4892764a2aaSMatthew G. Knepley 4902764a2aaSMatthew G. Knepley Output Parameter: 4912764a2aaSMatthew G. Knepley . prob - The PetscDS object 4922764a2aaSMatthew G. Knepley 4932764a2aaSMatthew G. Knepley Level: beginner 4942764a2aaSMatthew G. Knepley 4952764a2aaSMatthew G. Knepley .seealso: PetscDSSetType(), PETSCDSBASIC 4962764a2aaSMatthew G. Knepley @*/ 4972764a2aaSMatthew G. Knepley PetscErrorCode PetscDSCreate(MPI_Comm comm, PetscDS *prob) 4982764a2aaSMatthew G. Knepley { 4992764a2aaSMatthew G. Knepley PetscDS p; 5002764a2aaSMatthew G. Knepley PetscErrorCode ierr; 5012764a2aaSMatthew G. Knepley 5022764a2aaSMatthew G. Knepley PetscFunctionBegin; 5032764a2aaSMatthew G. Knepley PetscValidPointer(prob, 2); 5042764a2aaSMatthew G. Knepley *prob = NULL; 5052764a2aaSMatthew G. Knepley ierr = PetscDSInitializePackage();CHKERRQ(ierr); 5062764a2aaSMatthew G. Knepley 50773107ff1SLisandro Dalcin ierr = PetscHeaderCreate(p, PETSCDS_CLASSID, "PetscDS", "Discrete System", "PetscDS", comm, PetscDSDestroy, PetscDSView);CHKERRQ(ierr); 5082764a2aaSMatthew G. Knepley 5092764a2aaSMatthew G. Knepley p->Nf = 0; 5102764a2aaSMatthew G. Knepley p->setup = PETSC_FALSE; 5112764a2aaSMatthew G. Knepley 5122764a2aaSMatthew G. Knepley *prob = p; 5132764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5142764a2aaSMatthew G. Knepley } 5152764a2aaSMatthew G. Knepley 5162764a2aaSMatthew G. Knepley #undef __FUNCT__ 5172764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetNumFields" 518bc4ae4beSMatthew G. Knepley /*@ 519bc4ae4beSMatthew G. Knepley PetscDSGetNumFields - Returns the number of fields in the DS 520bc4ae4beSMatthew G. Knepley 521bc4ae4beSMatthew G. Knepley Not collective 522bc4ae4beSMatthew G. Knepley 523bc4ae4beSMatthew G. Knepley Input Parameter: 524bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 525bc4ae4beSMatthew G. Knepley 526bc4ae4beSMatthew G. Knepley Output Parameter: 527bc4ae4beSMatthew G. Knepley . Nf - The number of fields 528bc4ae4beSMatthew G. Knepley 529bc4ae4beSMatthew G. Knepley Level: beginner 530bc4ae4beSMatthew G. Knepley 531bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetSpatialDimension(), PetscDSCreate() 532bc4ae4beSMatthew G. Knepley @*/ 5332764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetNumFields(PetscDS prob, PetscInt *Nf) 5342764a2aaSMatthew G. Knepley { 5352764a2aaSMatthew G. Knepley PetscFunctionBegin; 5362764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 5372764a2aaSMatthew G. Knepley PetscValidPointer(Nf, 2); 5382764a2aaSMatthew G. Knepley *Nf = prob->Nf; 5392764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5402764a2aaSMatthew G. Knepley } 5412764a2aaSMatthew G. Knepley 5422764a2aaSMatthew G. Knepley #undef __FUNCT__ 5432764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetSpatialDimension" 544bc4ae4beSMatthew G. Knepley /*@ 545bc4ae4beSMatthew G. Knepley PetscDSGetSpatialDimension - Returns the spatial dimension of the DS 546bc4ae4beSMatthew G. Knepley 547bc4ae4beSMatthew G. Knepley Not collective 548bc4ae4beSMatthew G. Knepley 549bc4ae4beSMatthew G. Knepley Input Parameter: 550bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 551bc4ae4beSMatthew G. Knepley 552bc4ae4beSMatthew G. Knepley Output Parameter: 553bc4ae4beSMatthew G. Knepley . dim - The spatial dimension 554bc4ae4beSMatthew G. Knepley 555bc4ae4beSMatthew G. Knepley Level: beginner 556bc4ae4beSMatthew G. Knepley 557bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 558bc4ae4beSMatthew G. Knepley @*/ 5592764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetSpatialDimension(PetscDS prob, PetscInt *dim) 5602764a2aaSMatthew G. Knepley { 5612764a2aaSMatthew G. Knepley PetscErrorCode ierr; 5622764a2aaSMatthew G. Knepley 5632764a2aaSMatthew G. Knepley PetscFunctionBegin; 5642764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 5652764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 5662764a2aaSMatthew G. Knepley *dim = 0; 5679de99aefSMatthew G. Knepley if (prob->Nf) { 5689de99aefSMatthew G. Knepley PetscObject obj; 5699de99aefSMatthew G. Knepley PetscClassId id; 5709de99aefSMatthew G. Knepley 5719de99aefSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, 0, &obj);CHKERRQ(ierr); 5729de99aefSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 5739de99aefSMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEGetSpatialDimension((PetscFE) obj, dim);CHKERRQ(ierr);} 5749de99aefSMatthew G. Knepley else if (id == PETSCFV_CLASSID) {ierr = PetscFVGetSpatialDimension((PetscFV) obj, dim);CHKERRQ(ierr);} 5759de99aefSMatthew G. Knepley else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", 0); 5769de99aefSMatthew G. Knepley } 5772764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5782764a2aaSMatthew G. Knepley } 5792764a2aaSMatthew G. Knepley 5802764a2aaSMatthew G. Knepley #undef __FUNCT__ 5812764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalDimension" 582bc4ae4beSMatthew G. Knepley /*@ 583bc4ae4beSMatthew G. Knepley PetscDSGetTotalDimension - Returns the total size of the approximation space for this system 584bc4ae4beSMatthew G. Knepley 585bc4ae4beSMatthew G. Knepley Not collective 586bc4ae4beSMatthew G. Knepley 587bc4ae4beSMatthew G. Knepley Input Parameter: 588bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 589bc4ae4beSMatthew G. Knepley 590bc4ae4beSMatthew G. Knepley Output Parameter: 591bc4ae4beSMatthew G. Knepley . dim - The total problem dimension 592bc4ae4beSMatthew G. Knepley 593bc4ae4beSMatthew G. Knepley Level: beginner 594bc4ae4beSMatthew G. Knepley 595bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 596bc4ae4beSMatthew G. Knepley @*/ 5972764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalDimension(PetscDS prob, PetscInt *dim) 5982764a2aaSMatthew G. Knepley { 5992764a2aaSMatthew G. Knepley PetscErrorCode ierr; 6002764a2aaSMatthew G. Knepley 6012764a2aaSMatthew G. Knepley PetscFunctionBegin; 6022764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6032764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 6042764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 6052764a2aaSMatthew G. Knepley *dim = prob->totDim; 6062764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6072764a2aaSMatthew G. Knepley } 6082764a2aaSMatthew G. Knepley 6092764a2aaSMatthew G. Knepley #undef __FUNCT__ 6102764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalBdDimension" 611bc4ae4beSMatthew G. Knepley /*@ 612c3ac4435SMatthew G. Knepley PetscDSGetTotalBdDimension - Returns the total size of the boundary approximation space for this system 613bc4ae4beSMatthew G. Knepley 614bc4ae4beSMatthew G. Knepley Not collective 615bc4ae4beSMatthew G. Knepley 616bc4ae4beSMatthew G. Knepley Input Parameter: 617bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 618bc4ae4beSMatthew G. Knepley 619bc4ae4beSMatthew G. Knepley Output Parameter: 620bc4ae4beSMatthew G. Knepley . dim - The total boundary problem dimension 621bc4ae4beSMatthew G. Knepley 622bc4ae4beSMatthew G. Knepley Level: beginner 623bc4ae4beSMatthew G. Knepley 624bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 625bc4ae4beSMatthew G. Knepley @*/ 6262764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalBdDimension(PetscDS prob, PetscInt *dim) 6272764a2aaSMatthew G. Knepley { 6282764a2aaSMatthew G. Knepley PetscErrorCode ierr; 6292764a2aaSMatthew G. Knepley 6302764a2aaSMatthew G. Knepley PetscFunctionBegin; 6312764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6322764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 6332764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 6342764a2aaSMatthew G. Knepley *dim = prob->totDimBd; 6352764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6362764a2aaSMatthew G. Knepley } 6372764a2aaSMatthew G. Knepley 6382764a2aaSMatthew G. Knepley #undef __FUNCT__ 6392764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalComponents" 640bc4ae4beSMatthew G. Knepley /*@ 641bc4ae4beSMatthew G. Knepley PetscDSGetTotalComponents - Returns the total number of components in this system 642bc4ae4beSMatthew G. Knepley 643bc4ae4beSMatthew G. Knepley Not collective 644bc4ae4beSMatthew G. Knepley 645bc4ae4beSMatthew G. Knepley Input Parameter: 646bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 647bc4ae4beSMatthew G. Knepley 648bc4ae4beSMatthew G. Knepley Output Parameter: 649bc4ae4beSMatthew G. Knepley . dim - The total number of components 650bc4ae4beSMatthew G. Knepley 651bc4ae4beSMatthew G. Knepley Level: beginner 652bc4ae4beSMatthew G. Knepley 653bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 654bc4ae4beSMatthew G. Knepley @*/ 6552764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalComponents(PetscDS prob, PetscInt *Nc) 6562764a2aaSMatthew G. Knepley { 6572764a2aaSMatthew G. Knepley PetscErrorCode ierr; 6582764a2aaSMatthew G. Knepley 6592764a2aaSMatthew G. Knepley PetscFunctionBegin; 6602764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6612764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 6622764a2aaSMatthew G. Knepley PetscValidPointer(Nc, 2); 6632764a2aaSMatthew G. Knepley *Nc = prob->totComp; 6642764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6652764a2aaSMatthew G. Knepley } 6662764a2aaSMatthew G. Knepley 6672764a2aaSMatthew G. Knepley #undef __FUNCT__ 6682764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetDiscretization" 669bc4ae4beSMatthew G. Knepley /*@ 670bc4ae4beSMatthew G. Knepley PetscDSGetDiscretization - Returns the discretization object for the given field 671bc4ae4beSMatthew G. Knepley 672bc4ae4beSMatthew G. Knepley Not collective 673bc4ae4beSMatthew G. Knepley 674bc4ae4beSMatthew G. Knepley Input Parameters: 675bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 676bc4ae4beSMatthew G. Knepley - f - The field number 677bc4ae4beSMatthew G. Knepley 678bc4ae4beSMatthew G. Knepley Output Parameter: 679bc4ae4beSMatthew G. Knepley . disc - The discretization object 680bc4ae4beSMatthew G. Knepley 681bc4ae4beSMatthew G. Knepley Level: beginner 682bc4ae4beSMatthew G. Knepley 683bc4ae4beSMatthew G. Knepley .seealso: PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 684bc4ae4beSMatthew G. Knepley @*/ 6852764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetDiscretization(PetscDS prob, PetscInt f, PetscObject *disc) 6862764a2aaSMatthew G. Knepley { 6872764a2aaSMatthew G. Knepley PetscFunctionBegin; 6882764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6892764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 6902764a2aaSMatthew 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); 6912764a2aaSMatthew G. Knepley *disc = prob->disc[f]; 6922764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6932764a2aaSMatthew G. Knepley } 6942764a2aaSMatthew G. Knepley 6952764a2aaSMatthew G. Knepley #undef __FUNCT__ 6962764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdDiscretization" 697bc4ae4beSMatthew G. Knepley /*@ 698bc4ae4beSMatthew G. Knepley PetscDSGetBdDiscretization - Returns the boundary discretization object for the given field 699bc4ae4beSMatthew G. Knepley 700bc4ae4beSMatthew G. Knepley Not collective 701bc4ae4beSMatthew G. Knepley 702bc4ae4beSMatthew G. Knepley Input Parameters: 703bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 704bc4ae4beSMatthew G. Knepley - f - The field number 705bc4ae4beSMatthew G. Knepley 706bc4ae4beSMatthew G. Knepley Output Parameter: 707bc4ae4beSMatthew G. Knepley . disc - The boundary discretization object 708bc4ae4beSMatthew G. Knepley 709bc4ae4beSMatthew G. Knepley Level: beginner 710bc4ae4beSMatthew G. Knepley 711bc4ae4beSMatthew G. Knepley .seealso: PetscDSSetBdDiscretization(), PetscDSAddBdDiscretization(), PetscDSGetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 712bc4ae4beSMatthew G. Knepley @*/ 7132764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdDiscretization(PetscDS prob, PetscInt f, PetscObject *disc) 7142764a2aaSMatthew G. Knepley { 7152764a2aaSMatthew G. Knepley PetscFunctionBegin; 7162764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7172764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 7182764a2aaSMatthew 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); 7192764a2aaSMatthew G. Knepley *disc = prob->discBd[f]; 7202764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7212764a2aaSMatthew G. Knepley } 7222764a2aaSMatthew G. Knepley 7232764a2aaSMatthew G. Knepley #undef __FUNCT__ 7242764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetDiscretization" 725bc4ae4beSMatthew G. Knepley /*@ 726bc4ae4beSMatthew G. Knepley PetscDSSetDiscretization - Sets the discretization object for the given field 727bc4ae4beSMatthew G. Knepley 728bc4ae4beSMatthew G. Knepley Not collective 729bc4ae4beSMatthew G. Knepley 730bc4ae4beSMatthew G. Knepley Input Parameters: 731bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 732bc4ae4beSMatthew G. Knepley . f - The field number 733bc4ae4beSMatthew G. Knepley - disc - The discretization object 734bc4ae4beSMatthew G. Knepley 735bc4ae4beSMatthew G. Knepley Level: beginner 736bc4ae4beSMatthew G. Knepley 737bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 738bc4ae4beSMatthew G. Knepley @*/ 7392764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetDiscretization(PetscDS prob, PetscInt f, PetscObject disc) 7402764a2aaSMatthew G. Knepley { 7412764a2aaSMatthew G. Knepley PetscErrorCode ierr; 7422764a2aaSMatthew G. Knepley 7432764a2aaSMatthew G. Knepley PetscFunctionBegin; 7442764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7452764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 7462764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 7472764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 7482764a2aaSMatthew G. Knepley if (prob->disc[f]) {ierr = PetscObjectDereference(prob->disc[f]);CHKERRQ(ierr);} 7492764a2aaSMatthew G. Knepley prob->disc[f] = disc; 7502764a2aaSMatthew G. Knepley ierr = PetscObjectReference(disc);CHKERRQ(ierr); 751249df284SMatthew G. Knepley { 752249df284SMatthew G. Knepley PetscClassId id; 753249df284SMatthew G. Knepley 754249df284SMatthew G. Knepley ierr = PetscObjectGetClassId(disc, &id);CHKERRQ(ierr); 755a6cbbb48SMatthew G. Knepley if (id == PETSCFV_CLASSID) { 756a6cbbb48SMatthew G. Knepley prob->implicit[f] = PETSC_FALSE; 757a6cbbb48SMatthew G. Knepley prob->adjacency[f*2+0] = PETSC_TRUE; 758a6cbbb48SMatthew G. Knepley prob->adjacency[f*2+1] = PETSC_FALSE; 759a6cbbb48SMatthew G. Knepley } 760249df284SMatthew G. Knepley } 7612764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7622764a2aaSMatthew G. Knepley } 7632764a2aaSMatthew G. Knepley 7642764a2aaSMatthew G. Knepley #undef __FUNCT__ 7652764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdDiscretization" 766bc4ae4beSMatthew G. Knepley /*@ 767bc4ae4beSMatthew G. Knepley PetscDSSetBdDiscretization - Sets the boundary discretization object for the given field 768bc4ae4beSMatthew G. Knepley 769bc4ae4beSMatthew G. Knepley Not collective 770bc4ae4beSMatthew G. Knepley 771bc4ae4beSMatthew G. Knepley Input Parameters: 772bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 773bc4ae4beSMatthew G. Knepley . f - The field number 774bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object 775bc4ae4beSMatthew G. Knepley 776bc4ae4beSMatthew G. Knepley Level: beginner 777bc4ae4beSMatthew G. Knepley 778bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetBdDiscretization(), PetscDSAddBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 779bc4ae4beSMatthew G. Knepley @*/ 7802764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdDiscretization(PetscDS prob, PetscInt f, PetscObject disc) 7812764a2aaSMatthew G. Knepley { 7822764a2aaSMatthew G. Knepley PetscErrorCode ierr; 7832764a2aaSMatthew G. Knepley 7842764a2aaSMatthew G. Knepley PetscFunctionBegin; 7852764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7862764a2aaSMatthew G. Knepley if (disc) PetscValidPointer(disc, 3); 7872764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 7882764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 7892764a2aaSMatthew G. Knepley if (prob->discBd[f]) {ierr = PetscObjectDereference(prob->discBd[f]);CHKERRQ(ierr);} 7902764a2aaSMatthew G. Knepley prob->discBd[f] = disc; 7912764a2aaSMatthew G. Knepley ierr = PetscObjectReference(disc);CHKERRQ(ierr); 7922764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7932764a2aaSMatthew G. Knepley } 7942764a2aaSMatthew G. Knepley 7952764a2aaSMatthew G. Knepley #undef __FUNCT__ 7962764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSAddDiscretization" 797bc4ae4beSMatthew G. Knepley /*@ 798bc4ae4beSMatthew G. Knepley PetscDSAddDiscretization - Adds a discretization object 799bc4ae4beSMatthew G. Knepley 800bc4ae4beSMatthew G. Knepley Not collective 801bc4ae4beSMatthew G. Knepley 802bc4ae4beSMatthew G. Knepley Input Parameters: 803bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 804bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object 805bc4ae4beSMatthew G. Knepley 806bc4ae4beSMatthew G. Knepley Level: beginner 807bc4ae4beSMatthew G. Knepley 808bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSSetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 809bc4ae4beSMatthew G. Knepley @*/ 8102764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddDiscretization(PetscDS prob, PetscObject disc) 8112764a2aaSMatthew G. Knepley { 8122764a2aaSMatthew G. Knepley PetscErrorCode ierr; 8132764a2aaSMatthew G. Knepley 8142764a2aaSMatthew G. Knepley PetscFunctionBegin; 8152764a2aaSMatthew G. Knepley ierr = PetscDSSetDiscretization(prob, prob->Nf, disc);CHKERRQ(ierr); 8162764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8172764a2aaSMatthew G. Knepley } 8182764a2aaSMatthew G. Knepley 8192764a2aaSMatthew G. Knepley #undef __FUNCT__ 8202764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSAddBdDiscretization" 821bc4ae4beSMatthew G. Knepley /*@ 822bc4ae4beSMatthew G. Knepley PetscDSAddBdDiscretization - Adds a boundary discretization object 823bc4ae4beSMatthew G. Knepley 824bc4ae4beSMatthew G. Knepley Not collective 825bc4ae4beSMatthew G. Knepley 826bc4ae4beSMatthew G. Knepley Input Parameters: 827bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 828bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object 829bc4ae4beSMatthew G. Knepley 830bc4ae4beSMatthew G. Knepley Level: beginner 831bc4ae4beSMatthew G. Knepley 832bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetBdDiscretization(), PetscDSSetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 833bc4ae4beSMatthew G. Knepley @*/ 8342764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddBdDiscretization(PetscDS prob, PetscObject disc) 8352764a2aaSMatthew G. Knepley { 8362764a2aaSMatthew G. Knepley PetscErrorCode ierr; 8372764a2aaSMatthew G. Knepley 8382764a2aaSMatthew G. Knepley PetscFunctionBegin; 8392764a2aaSMatthew G. Knepley ierr = PetscDSSetBdDiscretization(prob, prob->Nf, disc);CHKERRQ(ierr); 8402764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8412764a2aaSMatthew G. Knepley } 8422764a2aaSMatthew G. Knepley 8432764a2aaSMatthew G. Knepley #undef __FUNCT__ 844249df284SMatthew G. Knepley #define __FUNCT__ "PetscDSGetImplicit" 845249df284SMatthew G. Knepley /*@ 846249df284SMatthew G. Knepley PetscDSGetImplicit - Returns the flag for implicit solve for this field. This is just a guide for IMEX 847249df284SMatthew G. Knepley 848249df284SMatthew G. Knepley Not collective 849249df284SMatthew G. Knepley 850249df284SMatthew G. Knepley Input Parameters: 851249df284SMatthew G. Knepley + prob - The PetscDS object 852249df284SMatthew G. Knepley - f - The field number 853249df284SMatthew G. Knepley 854249df284SMatthew G. Knepley Output Parameter: 855249df284SMatthew G. Knepley . implicit - The flag indicating what kind of solve to use for this field 856249df284SMatthew G. Knepley 857249df284SMatthew G. Knepley Level: developer 858249df284SMatthew G. Knepley 859249df284SMatthew G. Knepley .seealso: PetscDSSetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 860249df284SMatthew G. Knepley @*/ 861249df284SMatthew G. Knepley PetscErrorCode PetscDSGetImplicit(PetscDS prob, PetscInt f, PetscBool *implicit) 862249df284SMatthew G. Knepley { 863249df284SMatthew G. Knepley PetscFunctionBegin; 864249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 865249df284SMatthew G. Knepley PetscValidPointer(implicit, 3); 866249df284SMatthew 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); 867249df284SMatthew G. Knepley *implicit = prob->implicit[f]; 868249df284SMatthew G. Knepley PetscFunctionReturn(0); 869249df284SMatthew G. Knepley } 870249df284SMatthew G. Knepley 871249df284SMatthew G. Knepley #undef __FUNCT__ 872249df284SMatthew G. Knepley #define __FUNCT__ "PetscDSSetImplicit" 873249df284SMatthew G. Knepley /*@ 874249df284SMatthew G. Knepley PetscDSSetImplicit - Set the flag for implicit solve for this field. This is just a guide for IMEX 875249df284SMatthew G. Knepley 876249df284SMatthew G. Knepley Not collective 877249df284SMatthew G. Knepley 878249df284SMatthew G. Knepley Input Parameters: 879249df284SMatthew G. Knepley + prob - The PetscDS object 880249df284SMatthew G. Knepley . f - The field number 881249df284SMatthew G. Knepley - implicit - The flag indicating what kind of solve to use for this field 882249df284SMatthew G. Knepley 883249df284SMatthew G. Knepley Level: developer 884249df284SMatthew G. Knepley 885249df284SMatthew G. Knepley .seealso: PetscDSGetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 886249df284SMatthew G. Knepley @*/ 887249df284SMatthew G. Knepley PetscErrorCode PetscDSSetImplicit(PetscDS prob, PetscInt f, PetscBool implicit) 888249df284SMatthew G. Knepley { 889249df284SMatthew G. Knepley PetscFunctionBegin; 890249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 891249df284SMatthew 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); 892249df284SMatthew G. Knepley prob->implicit[f] = implicit; 893249df284SMatthew G. Knepley PetscFunctionReturn(0); 894249df284SMatthew G. Knepley } 895249df284SMatthew G. Knepley 896249df284SMatthew G. Knepley #undef __FUNCT__ 897a6cbbb48SMatthew G. Knepley #define __FUNCT__ "PetscDSGetAdjacency" 898a6cbbb48SMatthew G. Knepley /*@ 899a6cbbb48SMatthew G. Knepley PetscDSGetAdjacency - Returns the flags for determining variable influence 900a6cbbb48SMatthew G. Knepley 901a6cbbb48SMatthew G. Knepley Not collective 902a6cbbb48SMatthew G. Knepley 903a6cbbb48SMatthew G. Knepley Input Parameters: 904a6cbbb48SMatthew G. Knepley + prob - The PetscDS object 905a6cbbb48SMatthew G. Knepley - f - The field number 906a6cbbb48SMatthew G. Knepley 907a6cbbb48SMatthew G. Knepley Output Parameter: 908a6cbbb48SMatthew G. Knepley + useCone - Flag for variable influence starting with the cone operation 909a6cbbb48SMatthew G. Knepley - useClosure - Flag for variable influence using transitive closure 910a6cbbb48SMatthew G. Knepley 911a6cbbb48SMatthew G. Knepley Note: See the discussion in DMPlexGetAdjacencyUseCone() and DMPlexGetAdjacencyUseClosure() 912a6cbbb48SMatthew G. Knepley 913a6cbbb48SMatthew G. Knepley Level: developer 914a6cbbb48SMatthew G. Knepley 915a6cbbb48SMatthew G. Knepley .seealso: PetscDSSetAdjacency(), DMPlexGetAdjacencyUseCone(), DMPlexGetAdjacencyUseClosure(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 916a6cbbb48SMatthew G. Knepley @*/ 917a6cbbb48SMatthew G. Knepley PetscErrorCode PetscDSGetAdjacency(PetscDS prob, PetscInt f, PetscBool *useCone, PetscBool *useClosure) 918a6cbbb48SMatthew G. Knepley { 919a6cbbb48SMatthew G. Knepley PetscFunctionBegin; 920a6cbbb48SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 921a6cbbb48SMatthew G. Knepley PetscValidPointer(useCone, 3); 922a6cbbb48SMatthew G. Knepley PetscValidPointer(useClosure, 4); 923a6cbbb48SMatthew 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); 924a6cbbb48SMatthew G. Knepley *useCone = prob->adjacency[f*2+0]; 925a6cbbb48SMatthew G. Knepley *useClosure = prob->adjacency[f*2+1]; 926a6cbbb48SMatthew G. Knepley PetscFunctionReturn(0); 927a6cbbb48SMatthew G. Knepley } 928a6cbbb48SMatthew G. Knepley 929a6cbbb48SMatthew G. Knepley #undef __FUNCT__ 930a6cbbb48SMatthew G. Knepley #define __FUNCT__ "PetscDSSetAdjacency" 931a6cbbb48SMatthew G. Knepley /*@ 932a6cbbb48SMatthew G. Knepley PetscDSSetAdjacency - Set the flags for determining variable influence 933a6cbbb48SMatthew G. Knepley 934a6cbbb48SMatthew G. Knepley Not collective 935a6cbbb48SMatthew G. Knepley 936a6cbbb48SMatthew G. Knepley Input Parameters: 937a6cbbb48SMatthew G. Knepley + prob - The PetscDS object 938a6cbbb48SMatthew G. Knepley . f - The field number 939a6cbbb48SMatthew G. Knepley . useCone - Flag for variable influence starting with the cone operation 940a6cbbb48SMatthew G. Knepley - useClosure - Flag for variable influence using transitive closure 941a6cbbb48SMatthew G. Knepley 942a6cbbb48SMatthew G. Knepley Note: See the discussion in DMPlexGetAdjacencyUseCone() and DMPlexGetAdjacencyUseClosure() 943a6cbbb48SMatthew G. Knepley 944a6cbbb48SMatthew G. Knepley Level: developer 945a6cbbb48SMatthew G. Knepley 946a6cbbb48SMatthew G. Knepley .seealso: PetscDSGetAdjacency(), DMPlexGetAdjacencyUseCone(), DMPlexGetAdjacencyUseClosure(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 947a6cbbb48SMatthew G. Knepley @*/ 948a6cbbb48SMatthew G. Knepley PetscErrorCode PetscDSSetAdjacency(PetscDS prob, PetscInt f, PetscBool useCone, PetscBool useClosure) 949a6cbbb48SMatthew G. Knepley { 950a6cbbb48SMatthew G. Knepley PetscFunctionBegin; 951a6cbbb48SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 952a6cbbb48SMatthew 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); 953a6cbbb48SMatthew G. Knepley prob->adjacency[f*2+0] = useCone; 954a6cbbb48SMatthew G. Knepley prob->adjacency[f*2+1] = useClosure; 955a6cbbb48SMatthew G. Knepley PetscFunctionReturn(0); 956a6cbbb48SMatthew G. Knepley } 957a6cbbb48SMatthew G. Knepley 958a6cbbb48SMatthew G. Knepley #undef __FUNCT__ 9592764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetObjective" 9602764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetObjective(PetscDS prob, PetscInt f, 96130b9ff8bSMatthew G. Knepley void (**obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 962194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 963194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 96430b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar obj[])) 9652764a2aaSMatthew G. Knepley { 9662764a2aaSMatthew G. Knepley PetscFunctionBegin; 9672764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 9682764a2aaSMatthew G. Knepley PetscValidPointer(obj, 2); 9692764a2aaSMatthew 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); 9702764a2aaSMatthew G. Knepley *obj = prob->obj[f]; 9712764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9722764a2aaSMatthew G. Knepley } 9732764a2aaSMatthew G. Knepley 9742764a2aaSMatthew G. Knepley #undef __FUNCT__ 9752764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetObjective" 9762764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetObjective(PetscDS prob, PetscInt f, 97730b9ff8bSMatthew G. Knepley void (*obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 978194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 979194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 98030b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar obj[])) 9812764a2aaSMatthew G. Knepley { 9822764a2aaSMatthew G. Knepley PetscErrorCode ierr; 9832764a2aaSMatthew G. Knepley 9842764a2aaSMatthew G. Knepley PetscFunctionBegin; 9852764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 986de716cbcSToby Isaac if (obj) PetscValidFunction(obj, 2); 9872764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 9882764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 9892764a2aaSMatthew G. Knepley prob->obj[f] = obj; 9902764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9912764a2aaSMatthew G. Knepley } 9922764a2aaSMatthew G. Knepley 9932764a2aaSMatthew G. Knepley #undef __FUNCT__ 9942764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetResidual" 995194d53e6SMatthew G. Knepley /*@C 996194d53e6SMatthew G. Knepley PetscDSGetResidual - Get the pointwise residual function for a given test field 997194d53e6SMatthew G. Knepley 998194d53e6SMatthew G. Knepley Not collective 999194d53e6SMatthew G. Knepley 1000194d53e6SMatthew G. Knepley Input Parameters: 1001194d53e6SMatthew G. Knepley + prob - The PetscDS 1002194d53e6SMatthew G. Knepley - f - The test field number 1003194d53e6SMatthew G. Knepley 1004194d53e6SMatthew G. Knepley Output Parameters: 1005194d53e6SMatthew G. Knepley + f0 - integrand for the test function term 1006194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 1007194d53e6SMatthew G. Knepley 1008194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1009194d53e6SMatthew G. Knepley 1010194d53e6SMatthew 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) 1011194d53e6SMatthew G. Knepley 1012194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1013194d53e6SMatthew G. Knepley 101430b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1015194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1016194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 101730b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1018194d53e6SMatthew G. Knepley 1019194d53e6SMatthew G. Knepley + dim - the spatial dimension 1020194d53e6SMatthew G. Knepley . Nf - the number of fields 1021194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1022194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1023194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1024194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1025194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1026194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1027194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1028194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1029194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1030194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1031194d53e6SMatthew G. Knepley . t - current time 1032194d53e6SMatthew G. Knepley . x - coordinates of the current point 1033194d53e6SMatthew G. Knepley - f0 - output values at the current point 1034194d53e6SMatthew G. Knepley 1035194d53e6SMatthew G. Knepley Level: intermediate 1036194d53e6SMatthew G. Knepley 1037194d53e6SMatthew G. Knepley .seealso: PetscDSSetResidual() 1038194d53e6SMatthew G. Knepley @*/ 10392764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetResidual(PetscDS prob, PetscInt f, 104030b9ff8bSMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1041194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1042194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 104330b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar f0[]), 104430b9ff8bSMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1045194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1046194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 104730b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar f1[])) 10482764a2aaSMatthew G. Knepley { 10492764a2aaSMatthew G. Knepley PetscFunctionBegin; 10502764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 10512764a2aaSMatthew 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); 10522764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 3); *f0 = prob->f[f*2+0];} 10532764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 4); *f1 = prob->f[f*2+1];} 10542764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 10552764a2aaSMatthew G. Knepley } 10562764a2aaSMatthew G. Knepley 10572764a2aaSMatthew G. Knepley #undef __FUNCT__ 10582764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetResidual" 1059194d53e6SMatthew G. Knepley /*@C 1060194d53e6SMatthew G. Knepley PetscDSSetResidual - Set the pointwise residual function for a given test field 1061194d53e6SMatthew G. Knepley 1062194d53e6SMatthew G. Knepley Not collective 1063194d53e6SMatthew G. Knepley 1064194d53e6SMatthew G. Knepley Input Parameters: 1065194d53e6SMatthew G. Knepley + prob - The PetscDS 1066194d53e6SMatthew G. Knepley . f - The test field number 1067194d53e6SMatthew G. Knepley . f0 - integrand for the test function term 1068194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 1069194d53e6SMatthew G. Knepley 1070194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1071194d53e6SMatthew G. Knepley 1072194d53e6SMatthew 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) 1073194d53e6SMatthew G. Knepley 1074194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1075194d53e6SMatthew G. Knepley 107630b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1077194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1078194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 107930b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1080194d53e6SMatthew G. Knepley 1081194d53e6SMatthew G. Knepley + dim - the spatial dimension 1082194d53e6SMatthew G. Knepley . Nf - the number of fields 1083194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1084194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1085194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1086194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1087194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1088194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1089194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1090194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1091194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1092194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1093194d53e6SMatthew G. Knepley . t - current time 1094194d53e6SMatthew G. Knepley . x - coordinates of the current point 1095194d53e6SMatthew G. Knepley - f0 - output values at the current point 1096194d53e6SMatthew G. Knepley 1097194d53e6SMatthew G. Knepley Level: intermediate 1098194d53e6SMatthew G. Knepley 1099194d53e6SMatthew G. Knepley .seealso: PetscDSGetResidual() 1100194d53e6SMatthew G. Knepley @*/ 11012764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetResidual(PetscDS prob, PetscInt f, 110230b9ff8bSMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1103194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1104194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 110530b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar f0[]), 110630b9ff8bSMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1107194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1108194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 110930b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar f1[])) 11102764a2aaSMatthew G. Knepley { 11112764a2aaSMatthew G. Knepley PetscErrorCode ierr; 11122764a2aaSMatthew G. Knepley 11132764a2aaSMatthew G. Knepley PetscFunctionBegin; 11142764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1115f866a1d0SMatthew G. Knepley if (f0) PetscValidFunction(f0, 3); 1116f866a1d0SMatthew G. Knepley if (f1) PetscValidFunction(f1, 4); 11172764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 11182764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 11192764a2aaSMatthew G. Knepley prob->f[f*2+0] = f0; 11202764a2aaSMatthew G. Knepley prob->f[f*2+1] = f1; 11212764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 11222764a2aaSMatthew G. Knepley } 11232764a2aaSMatthew G. Knepley 11242764a2aaSMatthew G. Knepley #undef __FUNCT__ 11253e75805dSMatthew G. Knepley #define __FUNCT__ "PetscDSHasJacobian" 11263e75805dSMatthew G. Knepley /*@C 11273e75805dSMatthew G. Knepley PetscDSHasJacobian - Signals that Jacobian functions have been set 11283e75805dSMatthew G. Knepley 11293e75805dSMatthew G. Knepley Not collective 11303e75805dSMatthew G. Knepley 11313e75805dSMatthew G. Knepley Input Parameter: 11323e75805dSMatthew G. Knepley . prob - The PetscDS 11333e75805dSMatthew G. Knepley 11343e75805dSMatthew G. Knepley Output Parameter: 11353e75805dSMatthew G. Knepley . hasJac - flag that pointwise function for the Jacobian has been set 11363e75805dSMatthew G. Knepley 11373e75805dSMatthew G. Knepley Level: intermediate 11383e75805dSMatthew G. Knepley 11393e75805dSMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 11403e75805dSMatthew G. Knepley @*/ 11413e75805dSMatthew G. Knepley PetscErrorCode PetscDSHasJacobian(PetscDS prob, PetscBool *hasJac) 11423e75805dSMatthew G. Knepley { 11433e75805dSMatthew G. Knepley PetscInt f, g, h; 11443e75805dSMatthew G. Knepley 11453e75805dSMatthew G. Knepley PetscFunctionBegin; 11463e75805dSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 11473e75805dSMatthew G. Knepley *hasJac = PETSC_FALSE; 11483e75805dSMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 11493e75805dSMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 11503e75805dSMatthew G. Knepley for (h = 0; h < 4; ++h) { 11513e75805dSMatthew G. Knepley if (prob->g[(f*prob->Nf + g)*4+h]) *hasJac = PETSC_TRUE; 11523e75805dSMatthew G. Knepley } 11533e75805dSMatthew G. Knepley } 11543e75805dSMatthew G. Knepley } 11553e75805dSMatthew G. Knepley PetscFunctionReturn(0); 11563e75805dSMatthew G. Knepley } 11573e75805dSMatthew G. Knepley 11583e75805dSMatthew G. Knepley #undef __FUNCT__ 11592764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetJacobian" 1160194d53e6SMatthew G. Knepley /*@C 1161194d53e6SMatthew G. Knepley PetscDSGetJacobian - Get the pointwise Jacobian function for given test and basis field 1162194d53e6SMatthew G. Knepley 1163194d53e6SMatthew G. Knepley Not collective 1164194d53e6SMatthew G. Knepley 1165194d53e6SMatthew G. Knepley Input Parameters: 1166194d53e6SMatthew G. Knepley + prob - The PetscDS 1167194d53e6SMatthew G. Knepley . f - The test field number 1168194d53e6SMatthew G. Knepley - g - The field number 1169194d53e6SMatthew G. Knepley 1170194d53e6SMatthew G. Knepley Output Parameters: 1171194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 1172194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1173194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1174194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1175194d53e6SMatthew G. Knepley 1176194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1177194d53e6SMatthew G. Knepley 1178194d53e6SMatthew 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 1179194d53e6SMatthew G. Knepley 1180194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1181194d53e6SMatthew G. Knepley 118230b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1183194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1184194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 118530b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1186194d53e6SMatthew G. Knepley 1187194d53e6SMatthew G. Knepley + dim - the spatial dimension 1188194d53e6SMatthew G. Knepley . Nf - the number of fields 1189194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1190194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1191194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1192194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1193194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1194194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1195194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1196194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1197194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1198194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1199194d53e6SMatthew G. Knepley . t - current time 12002aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1201194d53e6SMatthew G. Knepley . x - coordinates of the current point 1202194d53e6SMatthew G. Knepley - g0 - output values at the current point 1203194d53e6SMatthew G. Knepley 1204194d53e6SMatthew G. Knepley Level: intermediate 1205194d53e6SMatthew G. Knepley 1206194d53e6SMatthew G. Knepley .seealso: PetscDSSetJacobian() 1207194d53e6SMatthew G. Knepley @*/ 12082764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetJacobian(PetscDS prob, PetscInt f, PetscInt g, 120930b9ff8bSMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1210194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1211194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 12122aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]), 121330b9ff8bSMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1214194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1215194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 12162aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]), 121730b9ff8bSMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1218194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1219194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 12202aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]), 122130b9ff8bSMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1222194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1223194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 12242aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[])) 12252764a2aaSMatthew G. Knepley { 12262764a2aaSMatthew G. Knepley PetscFunctionBegin; 12272764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 12282764a2aaSMatthew 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); 12292764a2aaSMatthew 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); 12302764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g[(f*prob->Nf + g)*4+0];} 12312764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g[(f*prob->Nf + g)*4+1];} 12322764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g[(f*prob->Nf + g)*4+2];} 12332764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g[(f*prob->Nf + g)*4+3];} 12342764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 12352764a2aaSMatthew G. Knepley } 12362764a2aaSMatthew G. Knepley 12372764a2aaSMatthew G. Knepley #undef __FUNCT__ 12382764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetJacobian" 1239194d53e6SMatthew G. Knepley /*@C 1240194d53e6SMatthew G. Knepley PetscDSSetJacobian - Set the pointwise Jacobian function for given test and basis fields 1241194d53e6SMatthew G. Knepley 1242194d53e6SMatthew G. Knepley Not collective 1243194d53e6SMatthew G. Knepley 1244194d53e6SMatthew G. Knepley Input Parameters: 1245194d53e6SMatthew G. Knepley + prob - The PetscDS 1246194d53e6SMatthew G. Knepley . f - The test field number 1247194d53e6SMatthew G. Knepley . g - The field number 1248194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 1249194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1250194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1251194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1252194d53e6SMatthew G. Knepley 1253194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1254194d53e6SMatthew G. Knepley 1255194d53e6SMatthew 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 1256194d53e6SMatthew G. Knepley 1257194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1258194d53e6SMatthew G. Knepley 125930b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1260194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1261194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 126230b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1263194d53e6SMatthew G. Knepley 1264194d53e6SMatthew G. Knepley + dim - the spatial dimension 1265194d53e6SMatthew G. Knepley . Nf - the number of fields 1266194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1267194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1268194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1269194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1270194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1271194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1272194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1273194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1274194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1275194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1276194d53e6SMatthew G. Knepley . t - current time 12772aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1278194d53e6SMatthew G. Knepley . x - coordinates of the current point 1279194d53e6SMatthew G. Knepley - g0 - output values at the current point 1280194d53e6SMatthew G. Knepley 1281194d53e6SMatthew G. Knepley Level: intermediate 1282194d53e6SMatthew G. Knepley 1283194d53e6SMatthew G. Knepley .seealso: PetscDSGetJacobian() 1284194d53e6SMatthew G. Knepley @*/ 12852764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetJacobian(PetscDS prob, PetscInt f, PetscInt g, 128630b9ff8bSMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1287194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1288194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 128930b9ff8bSMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]), 129030b9ff8bSMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1291194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1292194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 129330b9ff8bSMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]), 129430b9ff8bSMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1295194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1296194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 129730b9ff8bSMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]), 129830b9ff8bSMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1299194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1300194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 130130b9ff8bSMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[])) 13022764a2aaSMatthew G. Knepley { 13032764a2aaSMatthew G. Knepley PetscErrorCode ierr; 13042764a2aaSMatthew G. Knepley 13052764a2aaSMatthew G. Knepley PetscFunctionBegin; 13062764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 13072764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 13082764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 13092764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 13102764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 13112764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 13122764a2aaSMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 13132764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 13142764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+0] = g0; 13152764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+1] = g1; 13162764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+2] = g2; 13172764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+3] = g3; 13182764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 13192764a2aaSMatthew G. Knepley } 13202764a2aaSMatthew G. Knepley 13212764a2aaSMatthew G. Knepley #undef __FUNCT__ 1322475e0ac9SMatthew G. Knepley #define __FUNCT__ "PetscDSHasJacobianPreconditioner" 1323475e0ac9SMatthew G. Knepley /*@C 1324475e0ac9SMatthew G. Knepley PetscDSHasJacobianPreconditioner - Signals that a Jacobian preconditioner matrix has been set 1325475e0ac9SMatthew G. Knepley 1326475e0ac9SMatthew G. Knepley Not collective 1327475e0ac9SMatthew G. Knepley 1328475e0ac9SMatthew G. Knepley Input Parameter: 1329475e0ac9SMatthew G. Knepley . prob - The PetscDS 1330475e0ac9SMatthew G. Knepley 1331475e0ac9SMatthew G. Knepley Output Parameter: 1332475e0ac9SMatthew G. Knepley . hasJacPre - flag that pointwise function for Jacobian preconditioner matrix has been set 1333475e0ac9SMatthew G. Knepley 1334475e0ac9SMatthew G. Knepley Level: intermediate 1335475e0ac9SMatthew G. Knepley 1336475e0ac9SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 1337475e0ac9SMatthew G. Knepley @*/ 1338475e0ac9SMatthew G. Knepley PetscErrorCode PetscDSHasJacobianPreconditioner(PetscDS prob, PetscBool *hasJacPre) 1339475e0ac9SMatthew G. Knepley { 1340475e0ac9SMatthew G. Knepley PetscInt f, g, h; 1341475e0ac9SMatthew G. Knepley 1342475e0ac9SMatthew G. Knepley PetscFunctionBegin; 1343475e0ac9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1344475e0ac9SMatthew G. Knepley *hasJacPre = PETSC_FALSE; 1345475e0ac9SMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 1346475e0ac9SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 1347475e0ac9SMatthew G. Knepley for (h = 0; h < 4; ++h) { 1348475e0ac9SMatthew G. Knepley if (prob->gp[(f*prob->Nf + g)*4+h]) *hasJacPre = PETSC_TRUE; 1349475e0ac9SMatthew G. Knepley } 1350475e0ac9SMatthew G. Knepley } 1351475e0ac9SMatthew G. Knepley } 1352475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1353475e0ac9SMatthew G. Knepley } 1354475e0ac9SMatthew G. Knepley 1355475e0ac9SMatthew G. Knepley #undef __FUNCT__ 1356475e0ac9SMatthew G. Knepley #define __FUNCT__ "PetscDSGetJacobianPreconditioner" 1357475e0ac9SMatthew G. Knepley /*@C 1358475e0ac9SMatthew 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. 1359475e0ac9SMatthew G. Knepley 1360475e0ac9SMatthew G. Knepley Not collective 1361475e0ac9SMatthew G. Knepley 1362475e0ac9SMatthew G. Knepley Input Parameters: 1363475e0ac9SMatthew G. Knepley + prob - The PetscDS 1364475e0ac9SMatthew G. Knepley . f - The test field number 1365475e0ac9SMatthew G. Knepley - g - The field number 1366475e0ac9SMatthew G. Knepley 1367475e0ac9SMatthew G. Knepley Output Parameters: 1368475e0ac9SMatthew G. Knepley + g0 - integrand for the test and basis function term 1369475e0ac9SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1370475e0ac9SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1371475e0ac9SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1372475e0ac9SMatthew G. Knepley 1373475e0ac9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1374475e0ac9SMatthew G. Knepley 1375475e0ac9SMatthew 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 1376475e0ac9SMatthew G. Knepley 1377475e0ac9SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1378475e0ac9SMatthew G. Knepley 1379475e0ac9SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1380475e0ac9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1381475e0ac9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1382475e0ac9SMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1383475e0ac9SMatthew G. Knepley 1384475e0ac9SMatthew G. Knepley + dim - the spatial dimension 1385475e0ac9SMatthew G. Knepley . Nf - the number of fields 1386475e0ac9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1387475e0ac9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1388475e0ac9SMatthew G. Knepley . u - each field evaluated at the current point 1389475e0ac9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1390475e0ac9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1391475e0ac9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1392475e0ac9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1393475e0ac9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1394475e0ac9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1395475e0ac9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1396475e0ac9SMatthew G. Knepley . t - current time 1397475e0ac9SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1398475e0ac9SMatthew G. Knepley . x - coordinates of the current point 1399475e0ac9SMatthew G. Knepley - g0 - output values at the current point 1400475e0ac9SMatthew G. Knepley 1401475e0ac9SMatthew G. Knepley Level: intermediate 1402475e0ac9SMatthew G. Knepley 1403475e0ac9SMatthew G. Knepley .seealso: PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 1404475e0ac9SMatthew G. Knepley @*/ 1405475e0ac9SMatthew G. Knepley PetscErrorCode PetscDSGetJacobianPreconditioner(PetscDS prob, PetscInt f, PetscInt g, 1406475e0ac9SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1407475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1408475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1409475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]), 1410475e0ac9SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1411475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1412475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1413475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]), 1414475e0ac9SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1415475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1416475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1417475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]), 1418475e0ac9SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1419475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1420475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1421475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[])) 1422475e0ac9SMatthew G. Knepley { 1423475e0ac9SMatthew G. Knepley PetscFunctionBegin; 1424475e0ac9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1425475e0ac9SMatthew 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); 1426475e0ac9SMatthew 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); 1427475e0ac9SMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gp[(f*prob->Nf + g)*4+0];} 1428475e0ac9SMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gp[(f*prob->Nf + g)*4+1];} 1429475e0ac9SMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gp[(f*prob->Nf + g)*4+2];} 1430475e0ac9SMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gp[(f*prob->Nf + g)*4+3];} 1431475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1432475e0ac9SMatthew G. Knepley } 1433475e0ac9SMatthew G. Knepley 1434475e0ac9SMatthew G. Knepley #undef __FUNCT__ 1435475e0ac9SMatthew G. Knepley #define __FUNCT__ "PetscDSSetJacobianPreconditioner" 1436475e0ac9SMatthew G. Knepley /*@C 1437475e0ac9SMatthew 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. 1438475e0ac9SMatthew G. Knepley 1439475e0ac9SMatthew G. Knepley Not collective 1440475e0ac9SMatthew G. Knepley 1441475e0ac9SMatthew G. Knepley Input Parameters: 1442475e0ac9SMatthew G. Knepley + prob - The PetscDS 1443475e0ac9SMatthew G. Knepley . f - The test field number 1444475e0ac9SMatthew G. Knepley . g - The field number 1445475e0ac9SMatthew G. Knepley . g0 - integrand for the test and basis function term 1446475e0ac9SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1447475e0ac9SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1448475e0ac9SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1449475e0ac9SMatthew G. Knepley 1450475e0ac9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1451475e0ac9SMatthew G. Knepley 1452475e0ac9SMatthew 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 1453475e0ac9SMatthew G. Knepley 1454475e0ac9SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1455475e0ac9SMatthew G. Knepley 1456475e0ac9SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1457475e0ac9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1458475e0ac9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1459475e0ac9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1460475e0ac9SMatthew G. Knepley 1461475e0ac9SMatthew G. Knepley + dim - the spatial dimension 1462475e0ac9SMatthew G. Knepley . Nf - the number of fields 1463475e0ac9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1464475e0ac9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1465475e0ac9SMatthew G. Knepley . u - each field evaluated at the current point 1466475e0ac9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1467475e0ac9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1468475e0ac9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1469475e0ac9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1470475e0ac9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1471475e0ac9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1472475e0ac9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1473475e0ac9SMatthew G. Knepley . t - current time 1474475e0ac9SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1475475e0ac9SMatthew G. Knepley . x - coordinates of the current point 1476475e0ac9SMatthew G. Knepley - g0 - output values at the current point 1477475e0ac9SMatthew G. Knepley 1478475e0ac9SMatthew G. Knepley Level: intermediate 1479475e0ac9SMatthew G. Knepley 1480475e0ac9SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobian() 1481475e0ac9SMatthew G. Knepley @*/ 1482475e0ac9SMatthew G. Knepley PetscErrorCode PetscDSSetJacobianPreconditioner(PetscDS prob, PetscInt f, PetscInt g, 1483475e0ac9SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1484475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1485475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1486475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]), 1487475e0ac9SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1488475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1489475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1490475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]), 1491475e0ac9SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1492475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1493475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1494475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]), 1495475e0ac9SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1496475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1497475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1498475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[])) 1499475e0ac9SMatthew G. Knepley { 1500475e0ac9SMatthew G. Knepley PetscErrorCode ierr; 1501475e0ac9SMatthew G. Knepley 1502475e0ac9SMatthew G. Knepley PetscFunctionBegin; 1503475e0ac9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1504475e0ac9SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 1505475e0ac9SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 1506475e0ac9SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 1507475e0ac9SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 1508475e0ac9SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 1509475e0ac9SMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 1510475e0ac9SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 1511475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+0] = g0; 1512475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+1] = g1; 1513475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+2] = g2; 1514475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+3] = g3; 1515475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1516475e0ac9SMatthew G. Knepley } 1517475e0ac9SMatthew G. Knepley 1518475e0ac9SMatthew G. Knepley #undef __FUNCT__ 1519b7e05686SMatthew G. Knepley #define __FUNCT__ "PetscDSHasDynamicJacobian" 1520b7e05686SMatthew G. Knepley /*@C 1521b7e05686SMatthew G. Knepley PetscDSHasDynamicJacobian - Signals that a dynamic Jacobian, dF/du_t, has been set 1522b7e05686SMatthew G. Knepley 1523b7e05686SMatthew G. Knepley Not collective 1524b7e05686SMatthew G. Knepley 1525b7e05686SMatthew G. Knepley Input Parameter: 1526b7e05686SMatthew G. Knepley . prob - The PetscDS 1527b7e05686SMatthew G. Knepley 1528b7e05686SMatthew G. Knepley Output Parameter: 1529b7e05686SMatthew G. Knepley . hasDynJac - flag that pointwise function for dynamic Jacobian has been set 1530b7e05686SMatthew G. Knepley 1531b7e05686SMatthew G. Knepley Level: intermediate 1532b7e05686SMatthew G. Knepley 1533b7e05686SMatthew G. Knepley .seealso: PetscDSGetDynamicJacobian(), PetscDSSetDynamicJacobian(), PetscDSGetJacobian() 1534b7e05686SMatthew G. Knepley @*/ 1535b7e05686SMatthew G. Knepley PetscErrorCode PetscDSHasDynamicJacobian(PetscDS prob, PetscBool *hasDynJac) 1536b7e05686SMatthew G. Knepley { 1537b7e05686SMatthew G. Knepley PetscInt f, g, h; 1538b7e05686SMatthew G. Knepley 1539b7e05686SMatthew G. Knepley PetscFunctionBegin; 1540b7e05686SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1541b7e05686SMatthew G. Knepley *hasDynJac = PETSC_FALSE; 1542b7e05686SMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 1543b7e05686SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 1544b7e05686SMatthew G. Knepley for (h = 0; h < 4; ++h) { 1545b7e05686SMatthew G. Knepley if (prob->gt[(f*prob->Nf + g)*4+h]) *hasDynJac = PETSC_TRUE; 1546b7e05686SMatthew G. Knepley } 1547b7e05686SMatthew G. Knepley } 1548b7e05686SMatthew G. Knepley } 1549b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1550b7e05686SMatthew G. Knepley } 1551b7e05686SMatthew G. Knepley 1552b7e05686SMatthew G. Knepley #undef __FUNCT__ 1553b7e05686SMatthew G. Knepley #define __FUNCT__ "PetscDSGetDynamicJacobian" 1554b7e05686SMatthew G. Knepley /*@C 1555b7e05686SMatthew G. Knepley PetscDSGetDynamicJacobian - Get the pointwise dynamic Jacobian, dF/du_t, function for given test and basis field 1556b7e05686SMatthew G. Knepley 1557b7e05686SMatthew G. Knepley Not collective 1558b7e05686SMatthew G. Knepley 1559b7e05686SMatthew G. Knepley Input Parameters: 1560b7e05686SMatthew G. Knepley + prob - The PetscDS 1561b7e05686SMatthew G. Knepley . f - The test field number 1562b7e05686SMatthew G. Knepley - g - The field number 1563b7e05686SMatthew G. Knepley 1564b7e05686SMatthew G. Knepley Output Parameters: 1565b7e05686SMatthew G. Knepley + g0 - integrand for the test and basis function term 1566b7e05686SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1567b7e05686SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1568b7e05686SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1569b7e05686SMatthew G. Knepley 1570b7e05686SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1571b7e05686SMatthew G. Knepley 1572b7e05686SMatthew 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 1573b7e05686SMatthew G. Knepley 1574b7e05686SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1575b7e05686SMatthew G. Knepley 1576b7e05686SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1577b7e05686SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1578b7e05686SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1579b7e05686SMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1580b7e05686SMatthew G. Knepley 1581b7e05686SMatthew G. Knepley + dim - the spatial dimension 1582b7e05686SMatthew G. Knepley . Nf - the number of fields 1583b7e05686SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1584b7e05686SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1585b7e05686SMatthew G. Knepley . u - each field evaluated at the current point 1586b7e05686SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1587b7e05686SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1588b7e05686SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1589b7e05686SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1590b7e05686SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1591b7e05686SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1592b7e05686SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1593b7e05686SMatthew G. Knepley . t - current time 1594b7e05686SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1595b7e05686SMatthew G. Knepley . x - coordinates of the current point 1596b7e05686SMatthew G. Knepley - g0 - output values at the current point 1597b7e05686SMatthew G. Knepley 1598b7e05686SMatthew G. Knepley Level: intermediate 1599b7e05686SMatthew G. Knepley 1600b7e05686SMatthew G. Knepley .seealso: PetscDSSetJacobian() 1601b7e05686SMatthew G. Knepley @*/ 1602b7e05686SMatthew G. Knepley PetscErrorCode PetscDSGetDynamicJacobian(PetscDS prob, PetscInt f, PetscInt g, 1603b7e05686SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1604b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1605b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1606b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]), 1607b7e05686SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1608b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1609b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1610b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]), 1611b7e05686SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1612b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1613b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1614b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]), 1615b7e05686SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1616b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1617b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1618b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[])) 1619b7e05686SMatthew G. Knepley { 1620b7e05686SMatthew G. Knepley PetscFunctionBegin; 1621b7e05686SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1622b7e05686SMatthew 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); 1623b7e05686SMatthew 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); 1624b7e05686SMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gt[(f*prob->Nf + g)*4+0];} 1625b7e05686SMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gt[(f*prob->Nf + g)*4+1];} 1626b7e05686SMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gt[(f*prob->Nf + g)*4+2];} 1627b7e05686SMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gt[(f*prob->Nf + g)*4+3];} 1628b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1629b7e05686SMatthew G. Knepley } 1630b7e05686SMatthew G. Knepley 1631b7e05686SMatthew G. Knepley #undef __FUNCT__ 1632b7e05686SMatthew G. Knepley #define __FUNCT__ "PetscDSSetDynamicJacobian" 1633b7e05686SMatthew G. Knepley /*@C 1634b7e05686SMatthew G. Knepley PetscDSSetDynamicJacobian - Set the pointwise dynamic Jacobian, dF/du_t, function for given test and basis fields 1635b7e05686SMatthew G. Knepley 1636b7e05686SMatthew G. Knepley Not collective 1637b7e05686SMatthew G. Knepley 1638b7e05686SMatthew G. Knepley Input Parameters: 1639b7e05686SMatthew G. Knepley + prob - The PetscDS 1640b7e05686SMatthew G. Knepley . f - The test field number 1641b7e05686SMatthew G. Knepley . g - The field number 1642b7e05686SMatthew G. Knepley . g0 - integrand for the test and basis function term 1643b7e05686SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1644b7e05686SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1645b7e05686SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1646b7e05686SMatthew G. Knepley 1647b7e05686SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1648b7e05686SMatthew G. Knepley 1649b7e05686SMatthew 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 1650b7e05686SMatthew G. Knepley 1651b7e05686SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1652b7e05686SMatthew G. Knepley 1653b7e05686SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1654b7e05686SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1655b7e05686SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1656b7e05686SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1657b7e05686SMatthew G. Knepley 1658b7e05686SMatthew G. Knepley + dim - the spatial dimension 1659b7e05686SMatthew G. Knepley . Nf - the number of fields 1660b7e05686SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1661b7e05686SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1662b7e05686SMatthew G. Knepley . u - each field evaluated at the current point 1663b7e05686SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1664b7e05686SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1665b7e05686SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1666b7e05686SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1667b7e05686SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1668b7e05686SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1669b7e05686SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1670b7e05686SMatthew G. Knepley . t - current time 1671b7e05686SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1672b7e05686SMatthew G. Knepley . x - coordinates of the current point 1673b7e05686SMatthew G. Knepley - g0 - output values at the current point 1674b7e05686SMatthew G. Knepley 1675b7e05686SMatthew G. Knepley Level: intermediate 1676b7e05686SMatthew G. Knepley 1677b7e05686SMatthew G. Knepley .seealso: PetscDSGetJacobian() 1678b7e05686SMatthew G. Knepley @*/ 1679b7e05686SMatthew G. Knepley PetscErrorCode PetscDSSetDynamicJacobian(PetscDS prob, PetscInt f, PetscInt g, 1680b7e05686SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1681b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1682b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1683b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]), 1684b7e05686SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1685b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1686b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1687b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]), 1688b7e05686SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1689b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1690b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1691b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]), 1692b7e05686SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1693b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1694b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1695b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[])) 1696b7e05686SMatthew G. Knepley { 1697b7e05686SMatthew G. Knepley PetscErrorCode ierr; 1698b7e05686SMatthew G. Knepley 1699b7e05686SMatthew G. Knepley PetscFunctionBegin; 1700b7e05686SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1701b7e05686SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 1702b7e05686SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 1703b7e05686SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 1704b7e05686SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 1705b7e05686SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 1706b7e05686SMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 1707b7e05686SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 1708b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+0] = g0; 1709b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+1] = g1; 1710b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+2] = g2; 1711b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+3] = g3; 1712b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1713b7e05686SMatthew G. Knepley } 1714b7e05686SMatthew G. Knepley 1715b7e05686SMatthew G. Knepley #undef __FUNCT__ 17160c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSGetRiemannSolver" 17170c2f2876SMatthew G. Knepley /*@C 17180c2f2876SMatthew G. Knepley PetscDSGetRiemannSolver - Returns the Riemann solver for the given field 17190c2f2876SMatthew G. Knepley 17200c2f2876SMatthew G. Knepley Not collective 17210c2f2876SMatthew G. Knepley 17220c2f2876SMatthew G. Knepley Input Arguments: 17230c2f2876SMatthew G. Knepley + prob - The PetscDS object 17240c2f2876SMatthew G. Knepley - f - The field number 17250c2f2876SMatthew G. Knepley 17260c2f2876SMatthew G. Knepley Output Argument: 17270c2f2876SMatthew G. Knepley . r - Riemann solver 17280c2f2876SMatthew G. Knepley 17290c2f2876SMatthew G. Knepley Calling sequence for r: 17300c2f2876SMatthew G. Knepley 17315db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 17320c2f2876SMatthew G. Knepley 17335db36cf9SMatthew G. Knepley + dim - The spatial dimension 17345db36cf9SMatthew G. Knepley . Nf - The number of fields 17355db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 17360c2f2876SMatthew G. Knepley . n - The normal vector to the interface 17370c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 17380c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 17390c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 17400c2f2876SMatthew G. Knepley - ctx - optional user context 17410c2f2876SMatthew G. Knepley 17420c2f2876SMatthew G. Knepley Level: intermediate 17430c2f2876SMatthew G. Knepley 17440c2f2876SMatthew G. Knepley .seealso: PetscDSSetRiemannSolver() 17450c2f2876SMatthew G. Knepley @*/ 17460c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetRiemannSolver(PetscDS prob, PetscInt f, 17475db36cf9SMatthew G. Knepley void (**r)(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx)) 17480c2f2876SMatthew G. Knepley { 17490c2f2876SMatthew G. Knepley PetscFunctionBegin; 17500c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 17510c2f2876SMatthew 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); 17520c2f2876SMatthew G. Knepley PetscValidPointer(r, 3); 17530c2f2876SMatthew G. Knepley *r = prob->r[f]; 17540c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 17550c2f2876SMatthew G. Knepley } 17560c2f2876SMatthew G. Knepley 17570c2f2876SMatthew G. Knepley #undef __FUNCT__ 17580c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSSetRiemannSolver" 17590c2f2876SMatthew G. Knepley /*@C 17600c2f2876SMatthew G. Knepley PetscDSSetRiemannSolver - Sets the Riemann solver for the given field 17610c2f2876SMatthew G. Knepley 17620c2f2876SMatthew G. Knepley Not collective 17630c2f2876SMatthew G. Knepley 17640c2f2876SMatthew G. Knepley Input Arguments: 17650c2f2876SMatthew G. Knepley + prob - The PetscDS object 17660c2f2876SMatthew G. Knepley . f - The field number 17670c2f2876SMatthew G. Knepley - r - Riemann solver 17680c2f2876SMatthew G. Knepley 17690c2f2876SMatthew G. Knepley Calling sequence for r: 17700c2f2876SMatthew G. Knepley 17715db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 17720c2f2876SMatthew G. Knepley 17735db36cf9SMatthew G. Knepley + dim - The spatial dimension 17745db36cf9SMatthew G. Knepley . Nf - The number of fields 17755db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 17760c2f2876SMatthew G. Knepley . n - The normal vector to the interface 17770c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 17780c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 17790c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 17800c2f2876SMatthew G. Knepley - ctx - optional user context 17810c2f2876SMatthew G. Knepley 17820c2f2876SMatthew G. Knepley Level: intermediate 17830c2f2876SMatthew G. Knepley 17840c2f2876SMatthew G. Knepley .seealso: PetscDSGetRiemannSolver() 17850c2f2876SMatthew G. Knepley @*/ 17860c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetRiemannSolver(PetscDS prob, PetscInt f, 17875db36cf9SMatthew G. Knepley void (*r)(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx)) 17880c2f2876SMatthew G. Knepley { 17890c2f2876SMatthew G. Knepley PetscErrorCode ierr; 17900c2f2876SMatthew G. Knepley 17910c2f2876SMatthew G. Knepley PetscFunctionBegin; 17920c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1793de716cbcSToby Isaac if (r) PetscValidFunction(r, 3); 17940c2f2876SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 17950c2f2876SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 17960c2f2876SMatthew G. Knepley prob->r[f] = r; 17970c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 17980c2f2876SMatthew G. Knepley } 17990c2f2876SMatthew G. Knepley 18000c2f2876SMatthew G. Knepley #undef __FUNCT__ 18010c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSGetContext" 18020c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetContext(PetscDS prob, PetscInt f, void **ctx) 18030c2f2876SMatthew G. Knepley { 18040c2f2876SMatthew G. Knepley PetscFunctionBegin; 18050c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 18060c2f2876SMatthew 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); 18070c2f2876SMatthew G. Knepley PetscValidPointer(ctx, 3); 18080c2f2876SMatthew G. Knepley *ctx = prob->ctx[f]; 18090c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 18100c2f2876SMatthew G. Knepley } 18110c2f2876SMatthew G. Knepley 18120c2f2876SMatthew G. Knepley #undef __FUNCT__ 18130c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSSetContext" 18140c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetContext(PetscDS prob, PetscInt f, void *ctx) 18150c2f2876SMatthew G. Knepley { 18160c2f2876SMatthew G. Knepley PetscErrorCode ierr; 18170c2f2876SMatthew G. Knepley 18180c2f2876SMatthew G. Knepley PetscFunctionBegin; 18190c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 18200c2f2876SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 18210c2f2876SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 18220c2f2876SMatthew G. Knepley prob->ctx[f] = ctx; 18230c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 18240c2f2876SMatthew G. Knepley } 18250c2f2876SMatthew G. Knepley 18260c2f2876SMatthew G. Knepley #undef __FUNCT__ 18272764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdResidual" 1828194d53e6SMatthew G. Knepley /*@C 1829194d53e6SMatthew G. Knepley PetscDSGetBdResidual - Get the pointwise boundary residual function for a given test field 1830194d53e6SMatthew G. Knepley 1831194d53e6SMatthew G. Knepley Not collective 1832194d53e6SMatthew G. Knepley 1833194d53e6SMatthew G. Knepley Input Parameters: 1834194d53e6SMatthew G. Knepley + prob - The PetscDS 1835194d53e6SMatthew G. Knepley - f - The test field number 1836194d53e6SMatthew G. Knepley 1837194d53e6SMatthew G. Knepley Output Parameters: 1838194d53e6SMatthew G. Knepley + f0 - boundary integrand for the test function term 1839194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 1840194d53e6SMatthew G. Knepley 1841194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1842194d53e6SMatthew G. Knepley 1843194d53e6SMatthew 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 1844194d53e6SMatthew G. Knepley 1845194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1846194d53e6SMatthew G. Knepley 184730b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1848194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1849194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 185030b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 1851194d53e6SMatthew G. Knepley 1852194d53e6SMatthew G. Knepley + dim - the spatial dimension 1853194d53e6SMatthew G. Knepley . Nf - the number of fields 1854194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1855194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1856194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1857194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1858194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1859194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1860194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1861194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1862194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1863194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1864194d53e6SMatthew G. Knepley . t - current time 1865194d53e6SMatthew G. Knepley . x - coordinates of the current point 1866194d53e6SMatthew G. Knepley . n - unit normal at the current point 1867194d53e6SMatthew G. Knepley - f0 - output values at the current point 1868194d53e6SMatthew G. Knepley 1869194d53e6SMatthew G. Knepley Level: intermediate 1870194d53e6SMatthew G. Knepley 1871194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdResidual() 1872194d53e6SMatthew G. Knepley @*/ 18732764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdResidual(PetscDS prob, PetscInt f, 187430b9ff8bSMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1875194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1876194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 187730b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]), 187830b9ff8bSMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1879194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1880194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 188130b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f1[])) 18822764a2aaSMatthew G. Knepley { 18832764a2aaSMatthew G. Knepley PetscFunctionBegin; 18842764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 18852764a2aaSMatthew 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); 18862764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 3); *f0 = prob->fBd[f*2+0];} 18872764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 4); *f1 = prob->fBd[f*2+1];} 18882764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 18892764a2aaSMatthew G. Knepley } 18902764a2aaSMatthew G. Knepley 18912764a2aaSMatthew G. Knepley #undef __FUNCT__ 18922764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdResidual" 1893194d53e6SMatthew G. Knepley /*@C 1894194d53e6SMatthew G. Knepley PetscDSSetBdResidual - Get the pointwise boundary residual function for a given test field 1895194d53e6SMatthew G. Knepley 1896194d53e6SMatthew G. Knepley Not collective 1897194d53e6SMatthew G. Knepley 1898194d53e6SMatthew G. Knepley Input Parameters: 1899194d53e6SMatthew G. Knepley + prob - The PetscDS 1900194d53e6SMatthew G. Knepley . f - The test field number 1901194d53e6SMatthew G. Knepley . f0 - boundary integrand for the test function term 1902194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 1903194d53e6SMatthew G. Knepley 1904194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1905194d53e6SMatthew G. Knepley 1906194d53e6SMatthew 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 1907194d53e6SMatthew G. Knepley 1908194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1909194d53e6SMatthew G. Knepley 191030b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1911194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1912194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 191330b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 1914194d53e6SMatthew G. Knepley 1915194d53e6SMatthew G. Knepley + dim - the spatial dimension 1916194d53e6SMatthew G. Knepley . Nf - the number of fields 1917194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1918194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1919194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1920194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1921194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1922194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1923194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1924194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1925194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1926194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1927194d53e6SMatthew G. Knepley . t - current time 1928194d53e6SMatthew G. Knepley . x - coordinates of the current point 1929194d53e6SMatthew G. Knepley . n - unit normal at the current point 1930194d53e6SMatthew G. Knepley - f0 - output values at the current point 1931194d53e6SMatthew G. Knepley 1932194d53e6SMatthew G. Knepley Level: intermediate 1933194d53e6SMatthew G. Knepley 1934194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdResidual() 1935194d53e6SMatthew G. Knepley @*/ 19362764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdResidual(PetscDS prob, PetscInt f, 193730b9ff8bSMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1938194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1939194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 194030b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]), 194130b9ff8bSMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1942194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1943194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 194430b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f1[])) 19452764a2aaSMatthew G. Knepley { 19462764a2aaSMatthew G. Knepley PetscErrorCode ierr; 19472764a2aaSMatthew G. Knepley 19482764a2aaSMatthew G. Knepley PetscFunctionBegin; 19492764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 19502764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 19512764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 19522764a2aaSMatthew G. Knepley if (f0) {PetscValidFunction(f0, 3); prob->fBd[f*2+0] = f0;} 19532764a2aaSMatthew G. Knepley if (f1) {PetscValidFunction(f1, 4); prob->fBd[f*2+1] = f1;} 19542764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 19552764a2aaSMatthew G. Knepley } 19562764a2aaSMatthew G. Knepley 19572764a2aaSMatthew G. Knepley #undef __FUNCT__ 19582764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdJacobian" 1959194d53e6SMatthew G. Knepley /*@C 1960194d53e6SMatthew G. Knepley PetscDSGetBdJacobian - Get the pointwise boundary Jacobian function for given test and basis field 1961194d53e6SMatthew G. Knepley 1962194d53e6SMatthew G. Knepley Not collective 1963194d53e6SMatthew G. Knepley 1964194d53e6SMatthew G. Knepley Input Parameters: 1965194d53e6SMatthew G. Knepley + prob - The PetscDS 1966194d53e6SMatthew G. Knepley . f - The test field number 1967194d53e6SMatthew G. Knepley - g - The field number 1968194d53e6SMatthew G. Knepley 1969194d53e6SMatthew G. Knepley Output Parameters: 1970194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 1971194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1972194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1973194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1974194d53e6SMatthew G. Knepley 1975194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1976194d53e6SMatthew G. Knepley 1977194d53e6SMatthew 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 1978194d53e6SMatthew G. Knepley 1979194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1980194d53e6SMatthew G. Knepley 198130b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1982194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1983194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 198430b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 1985194d53e6SMatthew G. Knepley 1986194d53e6SMatthew G. Knepley + dim - the spatial dimension 1987194d53e6SMatthew G. Knepley . Nf - the number of fields 1988194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1989194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1990194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1991194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1992194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1993194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1994194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1995194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1996194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1997194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1998194d53e6SMatthew G. Knepley . t - current time 19992aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 2000194d53e6SMatthew G. Knepley . x - coordinates of the current point 2001194d53e6SMatthew G. Knepley . n - normal at the current point 2002194d53e6SMatthew G. Knepley - g0 - output values at the current point 2003194d53e6SMatthew G. Knepley 2004194d53e6SMatthew G. Knepley Level: intermediate 2005194d53e6SMatthew G. Knepley 2006194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdJacobian() 2007194d53e6SMatthew G. Knepley @*/ 20082764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdJacobian(PetscDS prob, PetscInt f, PetscInt g, 200930b9ff8bSMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2010194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2011194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 20122aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g0[]), 201330b9ff8bSMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2014194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2015194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 20162aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g1[]), 201730b9ff8bSMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2018194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2019194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 20202aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g2[]), 202130b9ff8bSMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2022194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2023194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 20242aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g3[])) 20252764a2aaSMatthew G. Knepley { 20262764a2aaSMatthew G. Knepley PetscFunctionBegin; 20272764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 20282764a2aaSMatthew 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); 20292764a2aaSMatthew 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); 20302764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gBd[(f*prob->Nf + g)*4+0];} 20312764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gBd[(f*prob->Nf + g)*4+1];} 20322764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gBd[(f*prob->Nf + g)*4+2];} 20332764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gBd[(f*prob->Nf + g)*4+3];} 20342764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 20352764a2aaSMatthew G. Knepley } 20362764a2aaSMatthew G. Knepley 20372764a2aaSMatthew G. Knepley #undef __FUNCT__ 20382764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdJacobian" 2039194d53e6SMatthew G. Knepley /*@C 2040194d53e6SMatthew G. Knepley PetscDSSetBdJacobian - Set the pointwise boundary Jacobian function for given test and basis field 2041194d53e6SMatthew G. Knepley 2042194d53e6SMatthew G. Knepley Not collective 2043194d53e6SMatthew G. Knepley 2044194d53e6SMatthew G. Knepley Input Parameters: 2045194d53e6SMatthew G. Knepley + prob - The PetscDS 2046194d53e6SMatthew G. Knepley . f - The test field number 2047194d53e6SMatthew G. Knepley . g - The field number 2048194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 2049194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 2050194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 2051194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 2052194d53e6SMatthew G. Knepley 2053194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2054194d53e6SMatthew G. Knepley 2055194d53e6SMatthew 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 2056194d53e6SMatthew G. Knepley 2057194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 2058194d53e6SMatthew G. Knepley 205930b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2060194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2061194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 206230b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 2063194d53e6SMatthew G. Knepley 2064194d53e6SMatthew G. Knepley + dim - the spatial dimension 2065194d53e6SMatthew G. Knepley . Nf - the number of fields 2066194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2067194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2068194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2069194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2070194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2071194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2072194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2073194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2074194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2075194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2076194d53e6SMatthew G. Knepley . t - current time 20772aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 2078194d53e6SMatthew G. Knepley . x - coordinates of the current point 2079194d53e6SMatthew G. Knepley . n - normal at the current point 2080194d53e6SMatthew G. Knepley - g0 - output values at the current point 2081194d53e6SMatthew G. Knepley 2082194d53e6SMatthew G. Knepley Level: intermediate 2083194d53e6SMatthew G. Knepley 2084194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdJacobian() 2085194d53e6SMatthew G. Knepley @*/ 20862764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdJacobian(PetscDS prob, PetscInt f, PetscInt g, 208730b9ff8bSMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2088194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2089194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 20902aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g0[]), 209130b9ff8bSMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2092194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2093194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 20942aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g1[]), 209530b9ff8bSMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2096194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2097194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 20982aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g2[]), 209930b9ff8bSMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2100194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2101194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 21022aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g3[])) 21032764a2aaSMatthew G. Knepley { 21042764a2aaSMatthew G. Knepley PetscErrorCode ierr; 21052764a2aaSMatthew G. Knepley 21062764a2aaSMatthew G. Knepley PetscFunctionBegin; 21072764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 21082764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 21092764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 21102764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 21112764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 21122764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 21132764a2aaSMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 21142764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 21152764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+0] = g0; 21162764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+1] = g1; 21172764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+2] = g2; 21182764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+3] = g3; 21192764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 21202764a2aaSMatthew G. Knepley } 21212764a2aaSMatthew G. Knepley 21222764a2aaSMatthew G. Knepley #undef __FUNCT__ 21234cd1e086SMatthew G. Knepley #define __FUNCT__ "PetscDSGetFieldIndex" 21244cd1e086SMatthew G. Knepley /*@ 21254cd1e086SMatthew G. Knepley PetscDSGetFieldIndex - Returns the index of the given field 21264cd1e086SMatthew G. Knepley 21274cd1e086SMatthew G. Knepley Not collective 21284cd1e086SMatthew G. Knepley 21294cd1e086SMatthew G. Knepley Input Parameters: 21304cd1e086SMatthew G. Knepley + prob - The PetscDS object 21314cd1e086SMatthew G. Knepley - disc - The discretization object 21324cd1e086SMatthew G. Knepley 21334cd1e086SMatthew G. Knepley Output Parameter: 21344cd1e086SMatthew G. Knepley . f - The field number 21354cd1e086SMatthew G. Knepley 21364cd1e086SMatthew G. Knepley Level: beginner 21374cd1e086SMatthew G. Knepley 21384cd1e086SMatthew G. Knepley .seealso: PetscGetDiscretization(), PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 21394cd1e086SMatthew G. Knepley @*/ 21404cd1e086SMatthew G. Knepley PetscErrorCode PetscDSGetFieldIndex(PetscDS prob, PetscObject disc, PetscInt *f) 21414cd1e086SMatthew G. Knepley { 21424cd1e086SMatthew G. Knepley PetscInt g; 21434cd1e086SMatthew G. Knepley 21444cd1e086SMatthew G. Knepley PetscFunctionBegin; 21454cd1e086SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 21464cd1e086SMatthew G. Knepley PetscValidPointer(f, 3); 21474cd1e086SMatthew G. Knepley *f = -1; 21484cd1e086SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) {if (disc == prob->disc[g]) break;} 21494cd1e086SMatthew G. Knepley if (g == prob->Nf) SETERRQ(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Field not found in PetscDS."); 21504cd1e086SMatthew G. Knepley *f = g; 21514cd1e086SMatthew G. Knepley PetscFunctionReturn(0); 21524cd1e086SMatthew G. Knepley } 21534cd1e086SMatthew G. Knepley 21544cd1e086SMatthew G. Knepley #undef __FUNCT__ 21554cd1e086SMatthew G. Knepley #define __FUNCT__ "PetscDSGetFieldSize" 21564cd1e086SMatthew G. Knepley /*@ 21574cd1e086SMatthew G. Knepley PetscDSGetFieldSize - Returns the size of the given field in the full space basis 21584cd1e086SMatthew G. Knepley 21594cd1e086SMatthew G. Knepley Not collective 21604cd1e086SMatthew G. Knepley 21614cd1e086SMatthew G. Knepley Input Parameters: 21624cd1e086SMatthew G. Knepley + prob - The PetscDS object 21634cd1e086SMatthew G. Knepley - f - The field number 21644cd1e086SMatthew G. Knepley 21654cd1e086SMatthew G. Knepley Output Parameter: 21664cd1e086SMatthew G. Knepley . size - The size 21674cd1e086SMatthew G. Knepley 21684cd1e086SMatthew G. Knepley Level: beginner 21694cd1e086SMatthew G. Knepley 21704cd1e086SMatthew G. Knepley .seealso: PetscDSGetFieldOffset(), PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 21714cd1e086SMatthew G. Knepley @*/ 21724cd1e086SMatthew G. Knepley PetscErrorCode PetscDSGetFieldSize(PetscDS prob, PetscInt f, PetscInt *size) 21734cd1e086SMatthew G. Knepley { 21744cd1e086SMatthew G. Knepley PetscClassId id; 21754cd1e086SMatthew G. Knepley PetscInt Nb, Nc; 21764cd1e086SMatthew G. Knepley PetscErrorCode ierr; 21774cd1e086SMatthew G. Knepley 21784cd1e086SMatthew G. Knepley PetscFunctionBegin; 21794cd1e086SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 21804cd1e086SMatthew G. Knepley PetscValidPointer(size, 3); 21814cd1e086SMatthew 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); 21824cd1e086SMatthew G. Knepley *size = 0; 21834cd1e086SMatthew G. Knepley ierr = PetscObjectGetClassId(prob->disc[f], &id);CHKERRQ(ierr); 21844cd1e086SMatthew G. Knepley if (id == PETSCFE_CLASSID) { 21854cd1e086SMatthew G. Knepley PetscFE fe = (PetscFE) prob->disc[f]; 21864cd1e086SMatthew G. Knepley 21874cd1e086SMatthew G. Knepley ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr); 21884cd1e086SMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 21894cd1e086SMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 21904cd1e086SMatthew G. Knepley PetscFV fv = (PetscFV) prob->disc[f]; 21914cd1e086SMatthew G. Knepley 21924cd1e086SMatthew G. Knepley Nb = 1; 21934cd1e086SMatthew G. Knepley ierr = PetscFVGetNumComponents(fv, &Nc);CHKERRQ(ierr); 21944cd1e086SMatthew G. Knepley } else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", f); 21954cd1e086SMatthew G. Knepley *size = Nb*Nc; 21964cd1e086SMatthew G. Knepley PetscFunctionReturn(0); 21974cd1e086SMatthew G. Knepley } 21984cd1e086SMatthew G. Knepley 21994cd1e086SMatthew G. Knepley #undef __FUNCT__ 22002764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetFieldOffset" 2201bc4ae4beSMatthew G. Knepley /*@ 2202bc4ae4beSMatthew G. Knepley PetscDSGetFieldOffset - Returns the offset of the given field in the full space basis 2203bc4ae4beSMatthew G. Knepley 2204bc4ae4beSMatthew G. Knepley Not collective 2205bc4ae4beSMatthew G. Knepley 2206bc4ae4beSMatthew G. Knepley Input Parameters: 2207bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 2208bc4ae4beSMatthew G. Knepley - f - The field number 2209bc4ae4beSMatthew G. Knepley 2210bc4ae4beSMatthew G. Knepley Output Parameter: 2211bc4ae4beSMatthew G. Knepley . off - The offset 2212bc4ae4beSMatthew G. Knepley 2213bc4ae4beSMatthew G. Knepley Level: beginner 2214bc4ae4beSMatthew G. Knepley 22154cd1e086SMatthew G. Knepley .seealso: PetscDSGetFieldSize(), PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 2216bc4ae4beSMatthew G. Knepley @*/ 22172764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetFieldOffset(PetscDS prob, PetscInt f, PetscInt *off) 22182764a2aaSMatthew G. Knepley { 22194cd1e086SMatthew G. Knepley PetscInt size, g; 22202764a2aaSMatthew G. Knepley PetscErrorCode ierr; 22212764a2aaSMatthew G. Knepley 22222764a2aaSMatthew G. Knepley PetscFunctionBegin; 22232764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 22242764a2aaSMatthew G. Knepley PetscValidPointer(off, 3); 22252764a2aaSMatthew 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); 22262764a2aaSMatthew G. Knepley *off = 0; 22272764a2aaSMatthew G. Knepley for (g = 0; g < f; ++g) { 22284cd1e086SMatthew G. Knepley ierr = PetscDSGetFieldSize(prob, g, &size);CHKERRQ(ierr); 22294cd1e086SMatthew G. Knepley *off += size; 22302764a2aaSMatthew G. Knepley } 22312764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 22322764a2aaSMatthew G. Knepley } 22332764a2aaSMatthew G. Knepley 22342764a2aaSMatthew G. Knepley #undef __FUNCT__ 22352764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdFieldOffset" 2236bc4ae4beSMatthew G. Knepley /*@ 2237c3ac4435SMatthew G. Knepley PetscDSGetBdFieldOffset - Returns the offset of the given field in the full space boundary basis 2238bc4ae4beSMatthew G. Knepley 2239bc4ae4beSMatthew G. Knepley Not collective 2240bc4ae4beSMatthew G. Knepley 2241bc4ae4beSMatthew G. Knepley Input Parameters: 2242bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 2243bc4ae4beSMatthew G. Knepley - f - The field number 2244bc4ae4beSMatthew G. Knepley 2245bc4ae4beSMatthew G. Knepley Output Parameter: 2246bc4ae4beSMatthew G. Knepley . off - The boundary offset 2247bc4ae4beSMatthew G. Knepley 2248bc4ae4beSMatthew G. Knepley Level: beginner 2249bc4ae4beSMatthew G. Knepley 2250bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 2251bc4ae4beSMatthew G. Knepley @*/ 22522764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdFieldOffset(PetscDS prob, PetscInt f, PetscInt *off) 22532764a2aaSMatthew G. Knepley { 22542764a2aaSMatthew G. Knepley PetscInt g; 22552764a2aaSMatthew G. Knepley PetscErrorCode ierr; 22562764a2aaSMatthew G. Knepley 22572764a2aaSMatthew G. Knepley PetscFunctionBegin; 22582764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 22592764a2aaSMatthew G. Knepley PetscValidPointer(off, 3); 22602764a2aaSMatthew 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); 22612764a2aaSMatthew G. Knepley *off = 0; 22622764a2aaSMatthew G. Knepley for (g = 0; g < f; ++g) { 22632764a2aaSMatthew G. Knepley PetscFE fe = (PetscFE) prob->discBd[g]; 22642764a2aaSMatthew G. Knepley PetscInt Nb, Nc; 22652764a2aaSMatthew G. Knepley 22662764a2aaSMatthew G. Knepley ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr); 22672764a2aaSMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 22682764a2aaSMatthew G. Knepley *off += Nb*Nc; 22696ce16762SMatthew G. Knepley } 22706ce16762SMatthew G. Knepley PetscFunctionReturn(0); 22716ce16762SMatthew G. Knepley } 22726ce16762SMatthew G. Knepley 22736ce16762SMatthew G. Knepley #undef __FUNCT__ 22746ce16762SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentOffset" 22756ce16762SMatthew G. Knepley /*@ 22766ce16762SMatthew G. Knepley PetscDSGetComponentOffset - Returns the offset of the given field on an evaluation point 22776ce16762SMatthew G. Knepley 22786ce16762SMatthew G. Knepley Not collective 22796ce16762SMatthew G. Knepley 22806ce16762SMatthew G. Knepley Input Parameters: 22816ce16762SMatthew G. Knepley + prob - The PetscDS object 22826ce16762SMatthew G. Knepley - f - The field number 22836ce16762SMatthew G. Knepley 22846ce16762SMatthew G. Knepley Output Parameter: 22856ce16762SMatthew G. Knepley . off - The offset 22866ce16762SMatthew G. Knepley 22876ce16762SMatthew G. Knepley Level: beginner 22886ce16762SMatthew G. Knepley 22896ce16762SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 22906ce16762SMatthew G. Knepley @*/ 22916ce16762SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffset(PetscDS prob, PetscInt f, PetscInt *off) 22926ce16762SMatthew G. Knepley { 22936ce16762SMatthew G. Knepley PetscInt g; 22946ce16762SMatthew G. Knepley PetscErrorCode ierr; 22956ce16762SMatthew G. Knepley 22966ce16762SMatthew G. Knepley PetscFunctionBegin; 22976ce16762SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 22986ce16762SMatthew G. Knepley PetscValidPointer(off, 3); 22996ce16762SMatthew 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); 23006ce16762SMatthew G. Knepley *off = 0; 23016ce16762SMatthew G. Knepley for (g = 0; g < f; ++g) { 23026ce16762SMatthew G. Knepley PetscFE fe = (PetscFE) prob->disc[g]; 23036ce16762SMatthew G. Knepley PetscInt Nc; 23046ce16762SMatthew G. Knepley 23056ce16762SMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 23066ce16762SMatthew G. Knepley *off += Nc; 23072764a2aaSMatthew G. Knepley } 23082764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 23092764a2aaSMatthew G. Knepley } 23102764a2aaSMatthew G. Knepley 23112764a2aaSMatthew G. Knepley #undef __FUNCT__ 2312194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentOffsets" 2313194d53e6SMatthew G. Knepley /*@ 2314194d53e6SMatthew G. Knepley PetscDSGetComponentOffsets - Returns the offset of each field on an evaluation point 2315194d53e6SMatthew G. Knepley 2316194d53e6SMatthew G. Knepley Not collective 2317194d53e6SMatthew G. Knepley 2318194d53e6SMatthew G. Knepley Input Parameter: 2319194d53e6SMatthew G. Knepley . prob - The PetscDS object 2320194d53e6SMatthew G. Knepley 2321194d53e6SMatthew G. Knepley Output Parameter: 2322194d53e6SMatthew G. Knepley . offsets - The offsets 2323194d53e6SMatthew G. Knepley 2324194d53e6SMatthew G. Knepley Level: beginner 2325194d53e6SMatthew G. Knepley 2326194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 2327194d53e6SMatthew G. Knepley @*/ 2328194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffsets(PetscDS prob, PetscInt *offsets[]) 2329194d53e6SMatthew G. Knepley { 2330194d53e6SMatthew G. Knepley PetscFunctionBegin; 2331194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2332194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 2333194d53e6SMatthew G. Knepley *offsets = prob->off; 2334194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 2335194d53e6SMatthew G. Knepley } 2336194d53e6SMatthew G. Knepley 2337194d53e6SMatthew G. Knepley #undef __FUNCT__ 2338194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentDerivativeOffsets" 2339194d53e6SMatthew G. Knepley /*@ 2340194d53e6SMatthew G. Knepley PetscDSGetComponentDerivativeOffsets - Returns the offset of each field derivative on an evaluation point 2341194d53e6SMatthew G. Knepley 2342194d53e6SMatthew G. Knepley Not collective 2343194d53e6SMatthew G. Knepley 2344194d53e6SMatthew G. Knepley Input Parameter: 2345194d53e6SMatthew G. Knepley . prob - The PetscDS object 2346194d53e6SMatthew G. Knepley 2347194d53e6SMatthew G. Knepley Output Parameter: 2348194d53e6SMatthew G. Knepley . offsets - The offsets 2349194d53e6SMatthew G. Knepley 2350194d53e6SMatthew G. Knepley Level: beginner 2351194d53e6SMatthew G. Knepley 2352194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 2353194d53e6SMatthew G. Knepley @*/ 2354194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentDerivativeOffsets(PetscDS prob, PetscInt *offsets[]) 2355194d53e6SMatthew G. Knepley { 2356194d53e6SMatthew G. Knepley PetscFunctionBegin; 2357194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2358194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 2359194d53e6SMatthew G. Knepley *offsets = prob->offDer; 2360194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 2361194d53e6SMatthew G. Knepley } 2362194d53e6SMatthew G. Knepley 2363194d53e6SMatthew G. Knepley #undef __FUNCT__ 2364194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentBdOffsets" 2365194d53e6SMatthew G. Knepley /*@ 2366194d53e6SMatthew G. Knepley PetscDSGetComponentBdOffsets - Returns the offset of each field on a boundary evaluation point 2367194d53e6SMatthew G. Knepley 2368194d53e6SMatthew G. Knepley Not collective 2369194d53e6SMatthew G. Knepley 2370194d53e6SMatthew G. Knepley Input Parameter: 2371194d53e6SMatthew G. Knepley . prob - The PetscDS object 2372194d53e6SMatthew G. Knepley 2373194d53e6SMatthew G. Knepley Output Parameter: 2374194d53e6SMatthew G. Knepley . offsets - The offsets 2375194d53e6SMatthew G. Knepley 2376194d53e6SMatthew G. Knepley Level: beginner 2377194d53e6SMatthew G. Knepley 2378194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 2379194d53e6SMatthew G. Knepley @*/ 2380194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentBdOffsets(PetscDS prob, PetscInt *offsets[]) 2381194d53e6SMatthew G. Knepley { 2382194d53e6SMatthew G. Knepley PetscFunctionBegin; 2383194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2384194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 2385194d53e6SMatthew G. Knepley *offsets = prob->offBd; 2386194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 2387194d53e6SMatthew G. Knepley } 2388194d53e6SMatthew G. Knepley 2389194d53e6SMatthew G. Knepley #undef __FUNCT__ 2390194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentBdDerivativeOffsets" 2391194d53e6SMatthew G. Knepley /*@ 2392194d53e6SMatthew G. Knepley PetscDSGetComponentBdDerivativeOffsets - Returns the offset of each field derivative on a boundary evaluation point 2393194d53e6SMatthew G. Knepley 2394194d53e6SMatthew G. Knepley Not collective 2395194d53e6SMatthew G. Knepley 2396194d53e6SMatthew G. Knepley Input Parameter: 2397194d53e6SMatthew G. Knepley . prob - The PetscDS object 2398194d53e6SMatthew G. Knepley 2399194d53e6SMatthew G. Knepley Output Parameter: 2400194d53e6SMatthew G. Knepley . offsets - The offsets 2401194d53e6SMatthew G. Knepley 2402194d53e6SMatthew G. Knepley Level: beginner 2403194d53e6SMatthew G. Knepley 2404194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 2405194d53e6SMatthew G. Knepley @*/ 2406194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentBdDerivativeOffsets(PetscDS prob, PetscInt *offsets[]) 2407194d53e6SMatthew G. Knepley { 2408194d53e6SMatthew G. Knepley PetscFunctionBegin; 2409194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2410194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 2411194d53e6SMatthew G. Knepley *offsets = prob->offDerBd; 2412194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 2413194d53e6SMatthew G. Knepley } 2414194d53e6SMatthew G. Knepley 2415194d53e6SMatthew G. Knepley #undef __FUNCT__ 24162764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTabulation" 241768c9edb9SMatthew G. Knepley /*@C 241868c9edb9SMatthew G. Knepley PetscDSGetTabulation - Return the basis tabulation at quadrature points for the volume discretization 241968c9edb9SMatthew G. Knepley 242068c9edb9SMatthew G. Knepley Not collective 242168c9edb9SMatthew G. Knepley 242268c9edb9SMatthew G. Knepley Input Parameter: 242368c9edb9SMatthew G. Knepley . prob - The PetscDS object 242468c9edb9SMatthew G. Knepley 242568c9edb9SMatthew G. Knepley Output Parameters: 242668c9edb9SMatthew G. Knepley + basis - The basis function tabulation at quadrature points 242768c9edb9SMatthew G. Knepley - basisDer - The basis function derivative tabulation at quadrature points 242868c9edb9SMatthew G. Knepley 242968c9edb9SMatthew G. Knepley Level: intermediate 243068c9edb9SMatthew G. Knepley 243168c9edb9SMatthew G. Knepley .seealso: PetscDSGetBdTabulation(), PetscDSCreate() 243268c9edb9SMatthew G. Knepley @*/ 24332764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTabulation(PetscDS prob, PetscReal ***basis, PetscReal ***basisDer) 24342764a2aaSMatthew G. Knepley { 24352764a2aaSMatthew G. Knepley PetscErrorCode ierr; 24362764a2aaSMatthew G. Knepley 24372764a2aaSMatthew G. Knepley PetscFunctionBegin; 24382764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 24392764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 24402764a2aaSMatthew G. Knepley if (basis) {PetscValidPointer(basis, 2); *basis = prob->basis;} 24412764a2aaSMatthew G. Knepley if (basisDer) {PetscValidPointer(basisDer, 3); *basisDer = prob->basisDer;} 24422764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 24432764a2aaSMatthew G. Knepley } 24442764a2aaSMatthew G. Knepley 24452764a2aaSMatthew G. Knepley #undef __FUNCT__ 24462764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdTabulation" 244768c9edb9SMatthew G. Knepley /*@C 244868c9edb9SMatthew G. Knepley PetscDSGetBdTabulation - Return the basis tabulation at quadrature points for the boundary discretization 244968c9edb9SMatthew G. Knepley 245068c9edb9SMatthew G. Knepley Not collective 245168c9edb9SMatthew G. Knepley 245268c9edb9SMatthew G. Knepley Input Parameter: 245368c9edb9SMatthew G. Knepley . prob - The PetscDS object 245468c9edb9SMatthew G. Knepley 245568c9edb9SMatthew G. Knepley Output Parameters: 245668c9edb9SMatthew G. Knepley + basis - The basis function tabulation at quadrature points 245768c9edb9SMatthew G. Knepley - basisDer - The basis function derivative tabulation at quadrature points 245868c9edb9SMatthew G. Knepley 245968c9edb9SMatthew G. Knepley Level: intermediate 246068c9edb9SMatthew G. Knepley 246168c9edb9SMatthew G. Knepley .seealso: PetscDSGetTabulation(), PetscDSCreate() 246268c9edb9SMatthew G. Knepley @*/ 24632764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdTabulation(PetscDS prob, PetscReal ***basis, PetscReal ***basisDer) 24642764a2aaSMatthew G. Knepley { 24652764a2aaSMatthew G. Knepley PetscErrorCode ierr; 24662764a2aaSMatthew G. Knepley 24672764a2aaSMatthew G. Knepley PetscFunctionBegin; 24682764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 24692764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 24702764a2aaSMatthew G. Knepley if (basis) {PetscValidPointer(basis, 2); *basis = prob->basisBd;} 24712764a2aaSMatthew G. Knepley if (basisDer) {PetscValidPointer(basisDer, 3); *basisDer = prob->basisDerBd;} 24722764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 24732764a2aaSMatthew G. Knepley } 24742764a2aaSMatthew G. Knepley 24752764a2aaSMatthew G. Knepley #undef __FUNCT__ 24762764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetEvaluationArrays" 24772764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetEvaluationArrays(PetscDS prob, PetscScalar **u, PetscScalar **u_t, PetscScalar **u_x) 24782764a2aaSMatthew G. Knepley { 24792764a2aaSMatthew G. Knepley PetscErrorCode ierr; 24802764a2aaSMatthew G. Knepley 24812764a2aaSMatthew G. Knepley PetscFunctionBegin; 24822764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 24832764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 24842764a2aaSMatthew G. Knepley if (u) {PetscValidPointer(u, 2); *u = prob->u;} 24852764a2aaSMatthew G. Knepley if (u_t) {PetscValidPointer(u_t, 3); *u_t = prob->u_t;} 24862764a2aaSMatthew G. Knepley if (u_x) {PetscValidPointer(u_x, 4); *u_x = prob->u_x;} 24872764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 24882764a2aaSMatthew G. Knepley } 24892764a2aaSMatthew G. Knepley 24902764a2aaSMatthew G. Knepley #undef __FUNCT__ 24912764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetWeakFormArrays" 24922764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetWeakFormArrays(PetscDS prob, PetscScalar **f0, PetscScalar **f1, PetscScalar **g0, PetscScalar **g1, PetscScalar **g2, PetscScalar **g3) 24932764a2aaSMatthew G. Knepley { 24942764a2aaSMatthew G. Knepley PetscErrorCode ierr; 24952764a2aaSMatthew G. Knepley 24962764a2aaSMatthew G. Knepley PetscFunctionBegin; 24972764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 24982764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 24992764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 2); *f0 = prob->f0;} 25002764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 3); *f1 = prob->f1;} 25012764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g0;} 25022764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g1;} 25032764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g2;} 25042764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g3;} 25052764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 25062764a2aaSMatthew G. Knepley } 25072764a2aaSMatthew G. Knepley 25082764a2aaSMatthew G. Knepley #undef __FUNCT__ 25092764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetRefCoordArrays" 25102764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetRefCoordArrays(PetscDS prob, PetscReal **x, PetscScalar **refSpaceDer) 25112764a2aaSMatthew G. Knepley { 25122764a2aaSMatthew G. Knepley PetscErrorCode ierr; 25132764a2aaSMatthew G. Knepley 25142764a2aaSMatthew G. Knepley PetscFunctionBegin; 25152764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 25162764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 25172764a2aaSMatthew G. Knepley if (x) {PetscValidPointer(x, 2); *x = prob->x;} 25182764a2aaSMatthew G. Knepley if (refSpaceDer) {PetscValidPointer(refSpaceDer, 3); *refSpaceDer = prob->refSpaceDer;} 25192764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 25202764a2aaSMatthew G. Knepley } 25212764a2aaSMatthew G. Knepley 25222764a2aaSMatthew G. Knepley #undef __FUNCT__ 252358ebd649SToby Isaac #define __FUNCT__ "PetscDSAddBoundary" 252458ebd649SToby Isaac /*@C 252558ebd649SToby Isaac PetscDSAddBoundary - Add a boundary condition to the model 252658ebd649SToby Isaac 252758ebd649SToby Isaac Input Parameters: 252858ebd649SToby Isaac + ds - The PetscDS object 252958ebd649SToby Isaac . isEssential - Flag for an essential (Dirichlet) condition, as opposed to a natural (Neumann) condition 253058ebd649SToby Isaac . name - The BC name 253158ebd649SToby Isaac . labelname - The label defining constrained points 253258ebd649SToby Isaac . field - The field to constrain 253358ebd649SToby Isaac . numcomps - The number of constrained field components 253458ebd649SToby Isaac . comps - An array of constrained component numbers 253558ebd649SToby Isaac . bcFunc - A pointwise function giving boundary values 253658ebd649SToby Isaac . numids - The number of DMLabel ids for constrained points 253758ebd649SToby Isaac . ids - An array of ids for constrained points 253858ebd649SToby Isaac - ctx - An optional user context for bcFunc 253958ebd649SToby Isaac 254058ebd649SToby Isaac Options Database Keys: 254158ebd649SToby Isaac + -bc_<boundary name> <num> - Overrides the boundary ids 254258ebd649SToby Isaac - -bc_<boundary name>_comp <num> - Overrides the boundary components 254358ebd649SToby Isaac 254458ebd649SToby Isaac Level: developer 254558ebd649SToby Isaac 254658ebd649SToby Isaac .seealso: PetscDSGetBoundary() 254758ebd649SToby Isaac @*/ 254858ebd649SToby 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) 254958ebd649SToby Isaac { 255058ebd649SToby Isaac DSBoundary b; 255158ebd649SToby Isaac PetscErrorCode ierr; 255258ebd649SToby Isaac 255358ebd649SToby Isaac PetscFunctionBegin; 255458ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 255558ebd649SToby Isaac ierr = PetscNew(&b);CHKERRQ(ierr); 255658ebd649SToby Isaac ierr = PetscStrallocpy(name, (char **) &b->name);CHKERRQ(ierr); 255758ebd649SToby Isaac ierr = PetscStrallocpy(labelname, (char **) &b->labelname);CHKERRQ(ierr); 255858ebd649SToby Isaac ierr = PetscMalloc1(numcomps, &b->comps);CHKERRQ(ierr); 255958ebd649SToby Isaac if (numcomps) {ierr = PetscMemcpy(b->comps, comps, numcomps*sizeof(PetscInt));CHKERRQ(ierr);} 256058ebd649SToby Isaac ierr = PetscMalloc1(numids, &b->ids);CHKERRQ(ierr); 256158ebd649SToby Isaac if (numids) {ierr = PetscMemcpy(b->ids, ids, numids*sizeof(PetscInt));CHKERRQ(ierr);} 256258ebd649SToby Isaac b->essential = isEssential; 256358ebd649SToby Isaac b->field = field; 256458ebd649SToby Isaac b->numcomps = numcomps; 256558ebd649SToby Isaac b->func = bcFunc; 256658ebd649SToby Isaac b->numids = numids; 256758ebd649SToby Isaac b->ctx = ctx; 256858ebd649SToby Isaac b->next = ds->boundary; 256958ebd649SToby Isaac ds->boundary = b; 257058ebd649SToby Isaac PetscFunctionReturn(0); 257158ebd649SToby Isaac } 257258ebd649SToby Isaac 257358ebd649SToby Isaac #undef __FUNCT__ 257458ebd649SToby Isaac #define __FUNCT__ "PetscDSGetNumBoundary" 257558ebd649SToby Isaac /*@ 257658ebd649SToby Isaac PetscDSGetNumBoundary - Get the number of registered BC 257758ebd649SToby Isaac 257858ebd649SToby Isaac Input Parameters: 257958ebd649SToby Isaac . ds - The PetscDS object 258058ebd649SToby Isaac 258158ebd649SToby Isaac Output Parameters: 258258ebd649SToby Isaac . numBd - The number of BC 258358ebd649SToby Isaac 258458ebd649SToby Isaac Level: intermediate 258558ebd649SToby Isaac 258658ebd649SToby Isaac .seealso: PetscDSAddBoundary(), PetscDSGetBoundary() 258758ebd649SToby Isaac @*/ 258858ebd649SToby Isaac PetscErrorCode PetscDSGetNumBoundary(PetscDS ds, PetscInt *numBd) 258958ebd649SToby Isaac { 259058ebd649SToby Isaac DSBoundary b = ds->boundary; 259158ebd649SToby Isaac 259258ebd649SToby Isaac PetscFunctionBegin; 259358ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 259458ebd649SToby Isaac PetscValidPointer(numBd, 2); 259558ebd649SToby Isaac *numBd = 0; 259658ebd649SToby Isaac while (b) {++(*numBd); b = b->next;} 259758ebd649SToby Isaac PetscFunctionReturn(0); 259858ebd649SToby Isaac } 259958ebd649SToby Isaac 260058ebd649SToby Isaac #undef __FUNCT__ 260158ebd649SToby Isaac #define __FUNCT__ "PetscDSGetBoundary" 260258ebd649SToby Isaac /*@C 260358ebd649SToby Isaac PetscDSGetBoundary - Add a boundary condition to the model 260458ebd649SToby Isaac 260558ebd649SToby Isaac Input Parameters: 260658ebd649SToby Isaac + ds - The PetscDS object 260758ebd649SToby Isaac - bd - The BC number 260858ebd649SToby Isaac 260958ebd649SToby Isaac Output Parameters: 261058ebd649SToby Isaac + isEssential - Flag for an essential (Dirichlet) condition, as opposed to a natural (Neumann) condition 261158ebd649SToby Isaac . name - The BC name 261258ebd649SToby Isaac . labelname - The label defining constrained points 261358ebd649SToby Isaac . field - The field to constrain 261458ebd649SToby Isaac . numcomps - The number of constrained field components 261558ebd649SToby Isaac . comps - An array of constrained component numbers 261658ebd649SToby Isaac . bcFunc - A pointwise function giving boundary values 261758ebd649SToby Isaac . numids - The number of DMLabel ids for constrained points 261858ebd649SToby Isaac . ids - An array of ids for constrained points 261958ebd649SToby Isaac - ctx - An optional user context for bcFunc 262058ebd649SToby Isaac 262158ebd649SToby Isaac Options Database Keys: 262258ebd649SToby Isaac + -bc_<boundary name> <num> - Overrides the boundary ids 262358ebd649SToby Isaac - -bc_<boundary name>_comp <num> - Overrides the boundary components 262458ebd649SToby Isaac 262558ebd649SToby Isaac Level: developer 262658ebd649SToby Isaac 262758ebd649SToby Isaac .seealso: PetscDSAddBoundary() 262858ebd649SToby Isaac @*/ 262958ebd649SToby 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) 263058ebd649SToby Isaac { 263158ebd649SToby Isaac DSBoundary b = ds->boundary; 263258ebd649SToby Isaac PetscInt n = 0; 263358ebd649SToby Isaac 263458ebd649SToby Isaac PetscFunctionBegin; 263558ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 263658ebd649SToby Isaac while (b) { 263758ebd649SToby Isaac if (n == bd) break; 263858ebd649SToby Isaac b = b->next; 263958ebd649SToby Isaac ++n; 264058ebd649SToby Isaac } 264158ebd649SToby Isaac if (!b) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Boundary %d is not in [0, %d)", bd, n); 264258ebd649SToby Isaac if (isEssential) { 264358ebd649SToby Isaac PetscValidPointer(isEssential, 3); 264458ebd649SToby Isaac *isEssential = b->essential; 264558ebd649SToby Isaac } 264658ebd649SToby Isaac if (name) { 264758ebd649SToby Isaac PetscValidPointer(name, 4); 264858ebd649SToby Isaac *name = b->name; 264958ebd649SToby Isaac } 265058ebd649SToby Isaac if (labelname) { 265158ebd649SToby Isaac PetscValidPointer(labelname, 5); 265258ebd649SToby Isaac *labelname = b->labelname; 265358ebd649SToby Isaac } 265458ebd649SToby Isaac if (field) { 265558ebd649SToby Isaac PetscValidPointer(field, 6); 265658ebd649SToby Isaac *field = b->field; 265758ebd649SToby Isaac } 265858ebd649SToby Isaac if (numcomps) { 265958ebd649SToby Isaac PetscValidPointer(numcomps, 7); 266058ebd649SToby Isaac *numcomps = b->numcomps; 266158ebd649SToby Isaac } 266258ebd649SToby Isaac if (comps) { 266358ebd649SToby Isaac PetscValidPointer(comps, 8); 266458ebd649SToby Isaac *comps = b->comps; 266558ebd649SToby Isaac } 266658ebd649SToby Isaac if (func) { 266758ebd649SToby Isaac PetscValidPointer(func, 9); 266858ebd649SToby Isaac *func = b->func; 266958ebd649SToby Isaac } 267058ebd649SToby Isaac if (numids) { 267158ebd649SToby Isaac PetscValidPointer(numids, 10); 267258ebd649SToby Isaac *numids = b->numids; 267358ebd649SToby Isaac } 267458ebd649SToby Isaac if (ids) { 267558ebd649SToby Isaac PetscValidPointer(ids, 11); 267658ebd649SToby Isaac *ids = b->ids; 267758ebd649SToby Isaac } 267858ebd649SToby Isaac if (ctx) { 267958ebd649SToby Isaac PetscValidPointer(ctx, 12); 268058ebd649SToby Isaac *ctx = b->ctx; 268158ebd649SToby Isaac } 268258ebd649SToby Isaac PetscFunctionReturn(0); 268358ebd649SToby Isaac } 268458ebd649SToby Isaac 268558ebd649SToby Isaac #undef __FUNCT__ 2686dff059c6SToby Isaac #define __FUNCT__ "PetscDSCopyBoundary" 2687dff059c6SToby Isaac PetscErrorCode PetscDSCopyBoundary(PetscDS probA, PetscDS probB) 2688dff059c6SToby Isaac { 2689dff059c6SToby Isaac DSBoundary b, next, *lastnext; 2690dff059c6SToby Isaac PetscErrorCode ierr; 2691dff059c6SToby Isaac 2692dff059c6SToby Isaac PetscFunctionBegin; 2693dff059c6SToby Isaac PetscValidHeaderSpecific(probA, PETSCDS_CLASSID, 1); 2694dff059c6SToby Isaac PetscValidHeaderSpecific(probB, PETSCDS_CLASSID, 2); 2695dff059c6SToby Isaac if (probA == probB) PetscFunctionReturn(0); 2696dff059c6SToby Isaac next = probB->boundary; 2697dff059c6SToby Isaac while (next) { 2698dff059c6SToby Isaac DSBoundary b = next; 2699dff059c6SToby Isaac 2700dff059c6SToby Isaac next = b->next; 2701dff059c6SToby Isaac ierr = PetscFree(b->comps);CHKERRQ(ierr); 2702dff059c6SToby Isaac ierr = PetscFree(b->ids);CHKERRQ(ierr); 2703dff059c6SToby Isaac ierr = PetscFree(b->name);CHKERRQ(ierr); 2704dff059c6SToby Isaac ierr = PetscFree(b->labelname);CHKERRQ(ierr); 2705dff059c6SToby Isaac ierr = PetscFree(b);CHKERRQ(ierr); 2706dff059c6SToby Isaac } 2707dff059c6SToby Isaac lastnext = &(probB->boundary); 2708dff059c6SToby Isaac for (b = probA->boundary; b; b = b->next) { 2709dff059c6SToby Isaac DSBoundary bNew; 2710dff059c6SToby Isaac 2711dff059c6SToby Isaac ierr = PetscNew(&bNew); 2712dff059c6SToby Isaac bNew->numcomps = b->numcomps; 2713dff059c6SToby Isaac ierr = PetscMalloc1(bNew->numcomps, &bNew->comps);CHKERRQ(ierr); 2714dff059c6SToby Isaac ierr = PetscMemcpy(bNew->comps, b->comps, bNew->numcomps*sizeof(PetscInt));CHKERRQ(ierr); 2715dff059c6SToby Isaac bNew->numids = b->numids; 2716dff059c6SToby Isaac ierr = PetscMalloc1(bNew->numids, &bNew->ids);CHKERRQ(ierr); 2717dff059c6SToby Isaac ierr = PetscMemcpy(bNew->ids, b->ids, bNew->numids*sizeof(PetscInt));CHKERRQ(ierr); 2718dff059c6SToby Isaac ierr = PetscStrallocpy(b->labelname,(char **) &(bNew->labelname));CHKERRQ(ierr); 2719dff059c6SToby Isaac ierr = PetscStrallocpy(b->name,(char **) &(bNew->name));CHKERRQ(ierr); 2720dff059c6SToby Isaac bNew->ctx = b->ctx; 2721dff059c6SToby Isaac bNew->essential = b->essential; 2722dff059c6SToby Isaac bNew->field = b->field; 2723dff059c6SToby Isaac bNew->func = b->func; 2724dff059c6SToby Isaac 2725dff059c6SToby Isaac *lastnext = bNew; 2726dff059c6SToby Isaac lastnext = &(bNew->next); 2727dff059c6SToby Isaac } 2728dff059c6SToby Isaac PetscFunctionReturn(0); 2729dff059c6SToby Isaac } 2730dff059c6SToby Isaac 2731dff059c6SToby Isaac #undef __FUNCT__ 2732da51fcedSMatthew G. Knepley #define __FUNCT__ "PetscDSCopyEquations" 2733da51fcedSMatthew G. Knepley /*@ 2734da51fcedSMatthew G. Knepley PetscDSCopyEquations - Copy all pointwise function pointers to the new problem 2735da51fcedSMatthew G. Knepley 2736da51fcedSMatthew G. Knepley Not collective 2737da51fcedSMatthew G. Knepley 2738da51fcedSMatthew G. Knepley Input Parameter: 2739da51fcedSMatthew G. Knepley . prob - The PetscDS object 2740da51fcedSMatthew G. Knepley 2741da51fcedSMatthew G. Knepley Output Parameter: 2742da51fcedSMatthew G. Knepley . newprob - The PetscDS copy 2743da51fcedSMatthew G. Knepley 2744da51fcedSMatthew G. Knepley Level: intermediate 2745da51fcedSMatthew G. Knepley 2746da51fcedSMatthew G. Knepley .seealso: PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 2747da51fcedSMatthew G. Knepley @*/ 2748da51fcedSMatthew G. Knepley PetscErrorCode PetscDSCopyEquations(PetscDS prob, PetscDS newprob) 2749da51fcedSMatthew G. Knepley { 2750da51fcedSMatthew G. Knepley PetscInt Nf, Ng, f, g; 2751da51fcedSMatthew G. Knepley PetscErrorCode ierr; 2752da51fcedSMatthew G. Knepley 2753da51fcedSMatthew G. Knepley PetscFunctionBegin; 2754da51fcedSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2755da51fcedSMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 2); 2756da51fcedSMatthew G. Knepley ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr); 2757da51fcedSMatthew G. Knepley ierr = PetscDSGetNumFields(newprob, &Ng);CHKERRQ(ierr); 2758da51fcedSMatthew G. Knepley if (Nf != Ng) SETERRQ2(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_SIZ, "Number of fields must match %D != %D", Nf, Ng);CHKERRQ(ierr); 2759da51fcedSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 2760da51fcedSMatthew G. Knepley PetscPointFunc obj; 2761da51fcedSMatthew G. Knepley PetscPointFunc f0, f1; 2762da51fcedSMatthew G. Knepley PetscPointJac g0, g1, g2, g3; 2763da51fcedSMatthew G. Knepley PetscBdPointFunc f0Bd, f1Bd; 2764da51fcedSMatthew G. Knepley PetscBdPointJac g0Bd, g1Bd, g2Bd, g3Bd; 2765da51fcedSMatthew G. Knepley PetscRiemannFunc r; 2766da51fcedSMatthew G. Knepley 2767da51fcedSMatthew G. Knepley ierr = PetscDSGetObjective(prob, f, &obj);CHKERRQ(ierr); 2768da51fcedSMatthew G. Knepley ierr = PetscDSGetResidual(prob, f, &f0, &f1);CHKERRQ(ierr); 2769da51fcedSMatthew G. Knepley ierr = PetscDSGetBdResidual(prob, f, &f0Bd, &f1Bd);CHKERRQ(ierr); 2770da51fcedSMatthew G. Knepley ierr = PetscDSGetRiemannSolver(prob, f, &r);CHKERRQ(ierr); 2771da51fcedSMatthew G. Knepley ierr = PetscDSSetObjective(newprob, f, obj);CHKERRQ(ierr); 2772da51fcedSMatthew G. Knepley ierr = PetscDSSetResidual(newprob, f, f0, f1);CHKERRQ(ierr); 2773da51fcedSMatthew G. Knepley ierr = PetscDSSetBdResidual(newprob, f, f0Bd, f1Bd);CHKERRQ(ierr); 2774da51fcedSMatthew G. Knepley ierr = PetscDSSetRiemannSolver(newprob, f, r);CHKERRQ(ierr); 2775da51fcedSMatthew G. Knepley for (g = 0; g < Nf; ++g) { 2776da51fcedSMatthew G. Knepley ierr = PetscDSGetJacobian(prob, f, g, &g0, &g1, &g2, &g3);CHKERRQ(ierr); 2777da51fcedSMatthew G. Knepley ierr = PetscDSGetBdJacobian(prob, f, g, &g0Bd, &g1Bd, &g2Bd, &g3Bd);CHKERRQ(ierr); 2778da51fcedSMatthew G. Knepley ierr = PetscDSSetJacobian(newprob, f, g, g0, g1, g2, g3);CHKERRQ(ierr); 2779da51fcedSMatthew G. Knepley ierr = PetscDSSetBdJacobian(newprob, f, g, g0Bd, g1Bd, g2Bd, g3Bd);CHKERRQ(ierr); 2780da51fcedSMatthew G. Knepley } 2781da51fcedSMatthew G. Knepley } 2782da51fcedSMatthew G. Knepley PetscFunctionReturn(0); 2783da51fcedSMatthew G. Knepley } 2784da51fcedSMatthew G. Knepley 2785da51fcedSMatthew G. Knepley #undef __FUNCT__ 27862764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroy_Basic" 2787bc4ae4beSMatthew G. Knepley static PetscErrorCode PetscDSDestroy_Basic(PetscDS prob) 27882764a2aaSMatthew G. Knepley { 2789931fb3b8SToby Isaac PetscErrorCode ierr; 2790931fb3b8SToby Isaac 27912764a2aaSMatthew G. Knepley PetscFunctionBegin; 2792931fb3b8SToby Isaac ierr = PetscFree(prob->data);CHKERRQ(ierr); 27932764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 27942764a2aaSMatthew G. Knepley } 27952764a2aaSMatthew G. Knepley 27962764a2aaSMatthew G. Knepley #undef __FUNCT__ 27972764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSInitialize_Basic" 2798bc4ae4beSMatthew G. Knepley static PetscErrorCode PetscDSInitialize_Basic(PetscDS prob) 27992764a2aaSMatthew G. Knepley { 28002764a2aaSMatthew G. Knepley PetscFunctionBegin; 28012764a2aaSMatthew G. Knepley prob->ops->setfromoptions = NULL; 28022764a2aaSMatthew G. Knepley prob->ops->setup = NULL; 28032764a2aaSMatthew G. Knepley prob->ops->view = NULL; 28042764a2aaSMatthew G. Knepley prob->ops->destroy = PetscDSDestroy_Basic; 28052764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 28062764a2aaSMatthew G. Knepley } 28072764a2aaSMatthew G. Knepley 28082764a2aaSMatthew G. Knepley /*MC 28092764a2aaSMatthew G. Knepley PETSCDSBASIC = "basic" - A discrete system with pointwise residual and boundary residual functions 28102764a2aaSMatthew G. Knepley 28112764a2aaSMatthew G. Knepley Level: intermediate 28122764a2aaSMatthew G. Knepley 28132764a2aaSMatthew G. Knepley .seealso: PetscDSType, PetscDSCreate(), PetscDSSetType() 28142764a2aaSMatthew G. Knepley M*/ 28152764a2aaSMatthew G. Knepley 28162764a2aaSMatthew G. Knepley #undef __FUNCT__ 28172764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSCreate_Basic" 28182764a2aaSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscDSCreate_Basic(PetscDS prob) 28192764a2aaSMatthew G. Knepley { 28202764a2aaSMatthew G. Knepley PetscDS_Basic *b; 28212764a2aaSMatthew G. Knepley PetscErrorCode ierr; 28222764a2aaSMatthew G. Knepley 28232764a2aaSMatthew G. Knepley PetscFunctionBegin; 2824931fb3b8SToby Isaac PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 28252764a2aaSMatthew G. Knepley ierr = PetscNewLog(prob, &b);CHKERRQ(ierr); 28262764a2aaSMatthew G. Knepley prob->data = b; 28272764a2aaSMatthew G. Knepley 28282764a2aaSMatthew G. Knepley ierr = PetscDSInitialize_Basic(prob);CHKERRQ(ierr); 28292764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 28302764a2aaSMatthew G. Knepley } 2831