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 { 2242764a2aaSMatthew G. Knepley const char *defaultType; 2252764a2aaSMatthew G. Knepley char name[256]; 2262764a2aaSMatthew G. Knepley PetscBool flg; 2272764a2aaSMatthew G. Knepley PetscErrorCode ierr; 2282764a2aaSMatthew G. Knepley 2292764a2aaSMatthew G. Knepley PetscFunctionBegin; 2302764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2312764a2aaSMatthew G. Knepley if (!((PetscObject) prob)->type_name) { 2322764a2aaSMatthew G. Knepley defaultType = PETSCDSBASIC; 2332764a2aaSMatthew G. Knepley } else { 2342764a2aaSMatthew G. Knepley defaultType = ((PetscObject) prob)->type_name; 2352764a2aaSMatthew G. Knepley } 2360f51fdf8SToby Isaac ierr = PetscDSRegisterAll();CHKERRQ(ierr); 2372764a2aaSMatthew G. Knepley 2382764a2aaSMatthew G. Knepley ierr = PetscObjectOptionsBegin((PetscObject) prob);CHKERRQ(ierr); 2392764a2aaSMatthew G. Knepley ierr = PetscOptionsFList("-petscds_type", "Discrete System", "PetscDSSetType", PetscDSList, defaultType, name, 256, &flg);CHKERRQ(ierr); 2402764a2aaSMatthew G. Knepley if (flg) { 2412764a2aaSMatthew G. Knepley ierr = PetscDSSetType(prob, name);CHKERRQ(ierr); 2422764a2aaSMatthew G. Knepley } else if (!((PetscObject) prob)->type_name) { 2432764a2aaSMatthew G. Knepley ierr = PetscDSSetType(prob, defaultType);CHKERRQ(ierr); 2442764a2aaSMatthew G. Knepley } 2452764a2aaSMatthew G. Knepley if (prob->ops->setfromoptions) {ierr = (*prob->ops->setfromoptions)(prob);CHKERRQ(ierr);} 2462764a2aaSMatthew G. Knepley /* process any options handlers added with PetscObjectAddOptionsHandler() */ 2470633abcbSJed Brown ierr = PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject) prob);CHKERRQ(ierr); 2482764a2aaSMatthew G. Knepley ierr = PetscOptionsEnd();CHKERRQ(ierr); 2492764a2aaSMatthew G. Knepley ierr = PetscDSViewFromOptions(prob, NULL, "-petscds_view");CHKERRQ(ierr); 2502764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 2512764a2aaSMatthew G. Knepley } 2522764a2aaSMatthew G. Knepley 2532764a2aaSMatthew G. Knepley #undef __FUNCT__ 2542764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetUp" 2552764a2aaSMatthew G. Knepley /*@C 2562764a2aaSMatthew G. Knepley PetscDSSetUp - Construct data structures for the PetscDS 2572764a2aaSMatthew G. Knepley 2582764a2aaSMatthew G. Knepley Collective on PetscDS 2592764a2aaSMatthew G. Knepley 2602764a2aaSMatthew G. Knepley Input Parameter: 2612764a2aaSMatthew G. Knepley . prob - the PetscDS object to setup 2622764a2aaSMatthew G. Knepley 2632764a2aaSMatthew G. Knepley Level: developer 2642764a2aaSMatthew G. Knepley 2652764a2aaSMatthew G. Knepley .seealso PetscDSView(), PetscDSDestroy() 2662764a2aaSMatthew G. Knepley @*/ 2672764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetUp(PetscDS prob) 2682764a2aaSMatthew G. Knepley { 2692764a2aaSMatthew G. Knepley const PetscInt Nf = prob->Nf; 2702764a2aaSMatthew G. Knepley PetscInt dim, work, NcMax = 0, NqMax = 0, f; 2712764a2aaSMatthew G. Knepley PetscErrorCode ierr; 2722764a2aaSMatthew G. Knepley 2732764a2aaSMatthew G. Knepley PetscFunctionBegin; 2742764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2752764a2aaSMatthew G. Knepley if (prob->setup) PetscFunctionReturn(0); 2762764a2aaSMatthew G. Knepley /* Calculate sizes */ 2772764a2aaSMatthew G. Knepley ierr = PetscDSGetSpatialDimension(prob, &dim);CHKERRQ(ierr); 2782764a2aaSMatthew G. Knepley prob->totDim = prob->totDimBd = prob->totComp = 0; 279194d53e6SMatthew G. Knepley ierr = PetscCalloc4(Nf+1,&prob->off,Nf+1,&prob->offDer,Nf+1,&prob->offBd,Nf+1,&prob->offDerBd);CHKERRQ(ierr); 2802764a2aaSMatthew G. Knepley ierr = PetscMalloc4(Nf,&prob->basis,Nf,&prob->basisDer,Nf,&prob->basisBd,Nf,&prob->basisDerBd);CHKERRQ(ierr); 2812764a2aaSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 2822764a2aaSMatthew G. Knepley PetscFE feBd = (PetscFE) prob->discBd[f]; 2839de99aefSMatthew G. Knepley PetscObject obj; 2849de99aefSMatthew G. Knepley PetscClassId id; 2852764a2aaSMatthew G. Knepley PetscQuadrature q; 2869de99aefSMatthew G. Knepley PetscInt Nq = 0, Nb, Nc; 2872764a2aaSMatthew G. Knepley 2889de99aefSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr); 2899de99aefSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 2909de99aefSMatthew G. Knepley if (id == PETSCFE_CLASSID) { 2919de99aefSMatthew G. Knepley PetscFE fe = (PetscFE) obj; 2929de99aefSMatthew G. Knepley 2932764a2aaSMatthew G. Knepley ierr = PetscFEGetQuadrature(fe, &q);CHKERRQ(ierr); 2942764a2aaSMatthew G. Knepley ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr); 2952764a2aaSMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 2962764a2aaSMatthew G. Knepley ierr = PetscFEGetDefaultTabulation(fe, &prob->basis[f], &prob->basisDer[f], NULL);CHKERRQ(ierr); 2979de99aefSMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 2989de99aefSMatthew G. Knepley PetscFV fv = (PetscFV) obj; 2999de99aefSMatthew G. Knepley 3009de99aefSMatthew G. Knepley ierr = PetscFVGetQuadrature(fv, &q);CHKERRQ(ierr); 3019de99aefSMatthew G. Knepley Nb = 1; 3029de99aefSMatthew G. Knepley ierr = PetscFVGetNumComponents(fv, &Nc);CHKERRQ(ierr); 3036c1a3d01SMatthew G. Knepley ierr = PetscFVGetDefaultTabulation(fv, &prob->basis[f], &prob->basisDer[f], NULL);CHKERRQ(ierr); 304abac5ca0SMatthew G. Knepley } else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", f); 305194d53e6SMatthew G. Knepley prob->off[f+1] = Nc + prob->off[f]; 306194d53e6SMatthew G. Knepley prob->offDer[f+1] = Nc*dim + prob->offDer[f]; 3079de99aefSMatthew G. Knepley if (q) {ierr = PetscQuadratureGetData(q, NULL, &Nq, NULL, NULL);CHKERRQ(ierr);} 3082764a2aaSMatthew G. Knepley NqMax = PetscMax(NqMax, Nq); 3092764a2aaSMatthew G. Knepley NcMax = PetscMax(NcMax, Nc); 3102764a2aaSMatthew G. Knepley prob->totDim += Nb*Nc; 3112764a2aaSMatthew G. Knepley prob->totComp += Nc; 3122764a2aaSMatthew G. Knepley if (feBd) { 3132764a2aaSMatthew G. Knepley ierr = PetscFEGetDimension(feBd, &Nb);CHKERRQ(ierr); 3142764a2aaSMatthew G. Knepley ierr = PetscFEGetNumComponents(feBd, &Nc);CHKERRQ(ierr); 3152764a2aaSMatthew G. Knepley ierr = PetscFEGetDefaultTabulation(feBd, &prob->basisBd[f], &prob->basisDerBd[f], NULL);CHKERRQ(ierr); 3162764a2aaSMatthew G. Knepley prob->totDimBd += Nb*Nc; 317194d53e6SMatthew G. Knepley prob->offBd[f+1] = Nc + prob->offBd[f]; 318194d53e6SMatthew G. Knepley prob->offDerBd[f+1] = Nc*dim + prob->offDerBd[f]; 3192764a2aaSMatthew G. Knepley } 3202764a2aaSMatthew G. Knepley } 3212764a2aaSMatthew G. Knepley work = PetscMax(prob->totComp*dim, PetscSqr(NcMax*dim)); 3222764a2aaSMatthew G. Knepley /* Allocate works space */ 3232764a2aaSMatthew 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); 3242764a2aaSMatthew 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); 3252764a2aaSMatthew G. Knepley if (prob->ops->setup) {ierr = (*prob->ops->setup)(prob);CHKERRQ(ierr);} 3262764a2aaSMatthew G. Knepley prob->setup = PETSC_TRUE; 3272764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 3282764a2aaSMatthew G. Knepley } 3292764a2aaSMatthew G. Knepley 3302764a2aaSMatthew G. Knepley #undef __FUNCT__ 3312764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroyStructs_Static" 3322764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSDestroyStructs_Static(PetscDS prob) 3332764a2aaSMatthew G. Knepley { 3342764a2aaSMatthew G. Knepley PetscErrorCode ierr; 3352764a2aaSMatthew G. Knepley 3362764a2aaSMatthew G. Knepley PetscFunctionBegin; 337194d53e6SMatthew G. Knepley ierr = PetscFree4(prob->off,prob->offDer,prob->offBd,prob->offDerBd);CHKERRQ(ierr); 3382764a2aaSMatthew G. Knepley ierr = PetscFree4(prob->basis,prob->basisDer,prob->basisBd,prob->basisDerBd);CHKERRQ(ierr); 3392764a2aaSMatthew G. Knepley ierr = PetscFree5(prob->u,prob->u_t,prob->u_x,prob->x,prob->refSpaceDer);CHKERRQ(ierr); 3402764a2aaSMatthew G. Knepley ierr = PetscFree6(prob->f0,prob->f1,prob->g0,prob->g1,prob->g2,prob->g3);CHKERRQ(ierr); 3412764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 3422764a2aaSMatthew G. Knepley } 3432764a2aaSMatthew G. Knepley 3442764a2aaSMatthew G. Knepley #undef __FUNCT__ 3452764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSEnlarge_Static" 3462764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSEnlarge_Static(PetscDS prob, PetscInt NfNew) 3472764a2aaSMatthew G. Knepley { 3482764a2aaSMatthew G. Knepley PetscObject *tmpd, *tmpdbd; 349a6cbbb48SMatthew G. Knepley PetscBool *tmpi, *tmpa; 3502aa1fc23SMatthew G. Knepley PetscPointFunc *tmpobj, *tmpf; 351b7e05686SMatthew G. Knepley PetscPointJac *tmpg, *tmpgp, *tmpgt; 3522aa1fc23SMatthew G. Knepley PetscBdPointFunc *tmpfbd; 3532aa1fc23SMatthew G. Knepley PetscBdPointJac *tmpgbd; 354194d53e6SMatthew G. Knepley PetscRiemannFunc *tmpr; 3550c2f2876SMatthew G. Knepley void **tmpctx; 356a6cbbb48SMatthew G. Knepley PetscInt Nf = prob->Nf, f, i; 3572764a2aaSMatthew G. Knepley PetscErrorCode ierr; 3582764a2aaSMatthew G. Knepley 3592764a2aaSMatthew G. Knepley PetscFunctionBegin; 3602764a2aaSMatthew G. Knepley if (Nf >= NfNew) PetscFunctionReturn(0); 3612764a2aaSMatthew G. Knepley prob->setup = PETSC_FALSE; 3622764a2aaSMatthew G. Knepley ierr = PetscDSDestroyStructs_Static(prob);CHKERRQ(ierr); 363a6cbbb48SMatthew G. Knepley ierr = PetscMalloc4(NfNew, &tmpd, NfNew, &tmpdbd, NfNew, &tmpi, NfNew*2, &tmpa);CHKERRQ(ierr); 364a6cbbb48SMatthew 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];} 365a6cbbb48SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) {ierr = PetscContainerCreate(PetscObjectComm((PetscObject) prob), (PetscContainer *) &tmpd[f]);CHKERRQ(ierr); 366a6cbbb48SMatthew G. Knepley tmpdbd[f] = NULL; tmpi[f] = PETSC_TRUE; tmpa[f*2+0] = PETSC_FALSE; tmpa[f*2+1] = PETSC_TRUE;} 367a6cbbb48SMatthew G. Knepley ierr = PetscFree4(prob->disc, prob->discBd, prob->implicit, prob->adjacency);CHKERRQ(ierr); 3682764a2aaSMatthew G. Knepley prob->Nf = NfNew; 3692764a2aaSMatthew G. Knepley prob->disc = tmpd; 370a6cbbb48SMatthew G. Knepley prob->discBd = tmpdbd; 371249df284SMatthew G. Knepley prob->implicit = tmpi; 372a6cbbb48SMatthew G. Knepley prob->adjacency = tmpa; 373b7e05686SMatthew 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); 3742764a2aaSMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpobj[f] = prob->obj[f]; 3752764a2aaSMatthew G. Knepley for (f = 0; f < Nf*2; ++f) tmpf[f] = prob->f[f]; 3762764a2aaSMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpg[f] = prob->g[f]; 377475e0ac9SMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpgp[f] = prob->gp[f]; 3780c2f2876SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpr[f] = prob->r[f]; 3790c2f2876SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpctx[f] = prob->ctx[f]; 3802764a2aaSMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpobj[f] = NULL; 3812764a2aaSMatthew G. Knepley for (f = Nf*2; f < NfNew*2; ++f) tmpf[f] = NULL; 3822764a2aaSMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpg[f] = NULL; 383475e0ac9SMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgp[f] = NULL; 384b7e05686SMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgt[f] = NULL; 3850c2f2876SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpr[f] = NULL; 3860c2f2876SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpctx[f] = NULL; 387b7e05686SMatthew G. Knepley ierr = PetscFree7(prob->obj, prob->f, prob->g, prob->gp, prob->gt, prob->r, prob->ctx);CHKERRQ(ierr); 3882764a2aaSMatthew G. Knepley prob->obj = tmpobj; 3892764a2aaSMatthew G. Knepley prob->f = tmpf; 3902764a2aaSMatthew G. Knepley prob->g = tmpg; 391475e0ac9SMatthew G. Knepley prob->gp = tmpgp; 392b7e05686SMatthew G. Knepley prob->gt = tmpgt; 3930c2f2876SMatthew G. Knepley prob->r = tmpr; 3940c2f2876SMatthew G. Knepley prob->ctx = tmpctx; 3952764a2aaSMatthew G. Knepley ierr = PetscCalloc2(NfNew*2, &tmpfbd, NfNew*NfNew*4, &tmpgbd);CHKERRQ(ierr); 3962764a2aaSMatthew G. Knepley for (f = 0; f < Nf*2; ++f) tmpfbd[f] = prob->fBd[f]; 3972764a2aaSMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpgbd[f] = prob->gBd[f]; 3982764a2aaSMatthew G. Knepley for (f = Nf*2; f < NfNew*2; ++f) tmpfbd[f] = NULL; 3992764a2aaSMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgbd[f] = NULL; 4002764a2aaSMatthew G. Knepley ierr = PetscFree2(prob->fBd, prob->gBd);CHKERRQ(ierr); 4012764a2aaSMatthew G. Knepley prob->fBd = tmpfbd; 4022764a2aaSMatthew G. Knepley prob->gBd = tmpgbd; 4032764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4042764a2aaSMatthew G. Knepley } 4052764a2aaSMatthew G. Knepley 4062764a2aaSMatthew G. Knepley #undef __FUNCT__ 4072764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroy" 4082764a2aaSMatthew G. Knepley /*@ 4092764a2aaSMatthew G. Knepley PetscDSDestroy - Destroys a PetscDS object 4102764a2aaSMatthew G. Knepley 4112764a2aaSMatthew G. Knepley Collective on PetscDS 4122764a2aaSMatthew G. Knepley 4132764a2aaSMatthew G. Knepley Input Parameter: 4142764a2aaSMatthew G. Knepley . prob - the PetscDS object to destroy 4152764a2aaSMatthew G. Knepley 4162764a2aaSMatthew G. Knepley Level: developer 4172764a2aaSMatthew G. Knepley 4182764a2aaSMatthew G. Knepley .seealso PetscDSView() 4192764a2aaSMatthew G. Knepley @*/ 4202764a2aaSMatthew G. Knepley PetscErrorCode PetscDSDestroy(PetscDS *prob) 4212764a2aaSMatthew G. Knepley { 4222764a2aaSMatthew G. Knepley PetscInt f; 423*58ebd649SToby Isaac DSBoundary next; 4242764a2aaSMatthew G. Knepley PetscErrorCode ierr; 4252764a2aaSMatthew G. Knepley 4262764a2aaSMatthew G. Knepley PetscFunctionBegin; 4272764a2aaSMatthew G. Knepley if (!*prob) PetscFunctionReturn(0); 4282764a2aaSMatthew G. Knepley PetscValidHeaderSpecific((*prob), PETSCDS_CLASSID, 1); 4292764a2aaSMatthew G. Knepley 4302764a2aaSMatthew G. Knepley if (--((PetscObject)(*prob))->refct > 0) {*prob = 0; PetscFunctionReturn(0);} 4312764a2aaSMatthew G. Knepley ((PetscObject) (*prob))->refct = 0; 4322764a2aaSMatthew G. Knepley ierr = PetscDSDestroyStructs_Static(*prob);CHKERRQ(ierr); 4332764a2aaSMatthew G. Knepley for (f = 0; f < (*prob)->Nf; ++f) { 4342764a2aaSMatthew G. Knepley ierr = PetscObjectDereference((*prob)->disc[f]);CHKERRQ(ierr); 4352764a2aaSMatthew G. Knepley ierr = PetscObjectDereference((*prob)->discBd[f]);CHKERRQ(ierr); 4362764a2aaSMatthew G. Knepley } 437a6cbbb48SMatthew G. Knepley ierr = PetscFree4((*prob)->disc, (*prob)->discBd, (*prob)->implicit, (*prob)->adjacency);CHKERRQ(ierr); 438b7e05686SMatthew G. Knepley ierr = PetscFree7((*prob)->obj,(*prob)->f,(*prob)->g,(*prob)->gp,(*prob)->gt,(*prob)->r,(*prob)->ctx);CHKERRQ(ierr); 4392764a2aaSMatthew G. Knepley ierr = PetscFree2((*prob)->fBd,(*prob)->gBd);CHKERRQ(ierr); 4402764a2aaSMatthew G. Knepley if ((*prob)->ops->destroy) {ierr = (*(*prob)->ops->destroy)(*prob);CHKERRQ(ierr);} 441*58ebd649SToby Isaac next = (*prob)->boundary; 442*58ebd649SToby Isaac while (next) { 443*58ebd649SToby Isaac DSBoundary b = next; 444*58ebd649SToby Isaac 445*58ebd649SToby Isaac next = b->next; 446*58ebd649SToby Isaac ierr = PetscFree(b->comps);CHKERRQ(ierr); 447*58ebd649SToby Isaac ierr = PetscFree(b->ids);CHKERRQ(ierr); 448*58ebd649SToby Isaac ierr = PetscFree(b->name);CHKERRQ(ierr); 449*58ebd649SToby Isaac ierr = PetscFree(b->labelname);CHKERRQ(ierr); 450*58ebd649SToby Isaac ierr = PetscFree(b);CHKERRQ(ierr); 451*58ebd649SToby Isaac } 4522764a2aaSMatthew G. Knepley ierr = PetscHeaderDestroy(prob);CHKERRQ(ierr); 4532764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4542764a2aaSMatthew G. Knepley } 4552764a2aaSMatthew G. Knepley 4562764a2aaSMatthew G. Knepley #undef __FUNCT__ 4572764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSCreate" 4582764a2aaSMatthew G. Knepley /*@ 4592764a2aaSMatthew G. Knepley PetscDSCreate - Creates an empty PetscDS object. The type can then be set with PetscDSSetType(). 4602764a2aaSMatthew G. Knepley 4612764a2aaSMatthew G. Knepley Collective on MPI_Comm 4622764a2aaSMatthew G. Knepley 4632764a2aaSMatthew G. Knepley Input Parameter: 4642764a2aaSMatthew G. Knepley . comm - The communicator for the PetscDS object 4652764a2aaSMatthew G. Knepley 4662764a2aaSMatthew G. Knepley Output Parameter: 4672764a2aaSMatthew G. Knepley . prob - The PetscDS object 4682764a2aaSMatthew G. Knepley 4692764a2aaSMatthew G. Knepley Level: beginner 4702764a2aaSMatthew G. Knepley 4712764a2aaSMatthew G. Knepley .seealso: PetscDSSetType(), PETSCDSBASIC 4722764a2aaSMatthew G. Knepley @*/ 4732764a2aaSMatthew G. Knepley PetscErrorCode PetscDSCreate(MPI_Comm comm, PetscDS *prob) 4742764a2aaSMatthew G. Knepley { 4752764a2aaSMatthew G. Knepley PetscDS p; 4762764a2aaSMatthew G. Knepley PetscErrorCode ierr; 4772764a2aaSMatthew G. Knepley 4782764a2aaSMatthew G. Knepley PetscFunctionBegin; 4792764a2aaSMatthew G. Knepley PetscValidPointer(prob, 2); 4802764a2aaSMatthew G. Knepley *prob = NULL; 4812764a2aaSMatthew G. Knepley ierr = PetscDSInitializePackage();CHKERRQ(ierr); 4822764a2aaSMatthew G. Knepley 48373107ff1SLisandro Dalcin ierr = PetscHeaderCreate(p, PETSCDS_CLASSID, "PetscDS", "Discrete System", "PetscDS", comm, PetscDSDestroy, PetscDSView);CHKERRQ(ierr); 4842764a2aaSMatthew G. Knepley 4852764a2aaSMatthew G. Knepley p->Nf = 0; 4862764a2aaSMatthew G. Knepley p->setup = PETSC_FALSE; 4872764a2aaSMatthew G. Knepley 4882764a2aaSMatthew G. Knepley *prob = p; 4892764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4902764a2aaSMatthew G. Knepley } 4912764a2aaSMatthew G. Knepley 4922764a2aaSMatthew G. Knepley #undef __FUNCT__ 4932764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetNumFields" 494bc4ae4beSMatthew G. Knepley /*@ 495bc4ae4beSMatthew G. Knepley PetscDSGetNumFields - Returns the number of fields in the DS 496bc4ae4beSMatthew G. Knepley 497bc4ae4beSMatthew G. Knepley Not collective 498bc4ae4beSMatthew G. Knepley 499bc4ae4beSMatthew G. Knepley Input Parameter: 500bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 501bc4ae4beSMatthew G. Knepley 502bc4ae4beSMatthew G. Knepley Output Parameter: 503bc4ae4beSMatthew G. Knepley . Nf - The number of fields 504bc4ae4beSMatthew G. Knepley 505bc4ae4beSMatthew G. Knepley Level: beginner 506bc4ae4beSMatthew G. Knepley 507bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetSpatialDimension(), PetscDSCreate() 508bc4ae4beSMatthew G. Knepley @*/ 5092764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetNumFields(PetscDS prob, PetscInt *Nf) 5102764a2aaSMatthew G. Knepley { 5112764a2aaSMatthew G. Knepley PetscFunctionBegin; 5122764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 5132764a2aaSMatthew G. Knepley PetscValidPointer(Nf, 2); 5142764a2aaSMatthew G. Knepley *Nf = prob->Nf; 5152764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5162764a2aaSMatthew G. Knepley } 5172764a2aaSMatthew G. Knepley 5182764a2aaSMatthew G. Knepley #undef __FUNCT__ 5192764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetSpatialDimension" 520bc4ae4beSMatthew G. Knepley /*@ 521bc4ae4beSMatthew G. Knepley PetscDSGetSpatialDimension - Returns the spatial dimension of the DS 522bc4ae4beSMatthew G. Knepley 523bc4ae4beSMatthew G. Knepley Not collective 524bc4ae4beSMatthew G. Knepley 525bc4ae4beSMatthew G. Knepley Input Parameter: 526bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 527bc4ae4beSMatthew G. Knepley 528bc4ae4beSMatthew G. Knepley Output Parameter: 529bc4ae4beSMatthew G. Knepley . dim - The spatial dimension 530bc4ae4beSMatthew G. Knepley 531bc4ae4beSMatthew G. Knepley Level: beginner 532bc4ae4beSMatthew G. Knepley 533bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 534bc4ae4beSMatthew G. Knepley @*/ 5352764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetSpatialDimension(PetscDS prob, PetscInt *dim) 5362764a2aaSMatthew G. Knepley { 5372764a2aaSMatthew G. Knepley PetscErrorCode ierr; 5382764a2aaSMatthew G. Knepley 5392764a2aaSMatthew G. Knepley PetscFunctionBegin; 5402764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 5412764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 5422764a2aaSMatthew G. Knepley *dim = 0; 5439de99aefSMatthew G. Knepley if (prob->Nf) { 5449de99aefSMatthew G. Knepley PetscObject obj; 5459de99aefSMatthew G. Knepley PetscClassId id; 5469de99aefSMatthew G. Knepley 5479de99aefSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, 0, &obj);CHKERRQ(ierr); 5489de99aefSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 5499de99aefSMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEGetSpatialDimension((PetscFE) obj, dim);CHKERRQ(ierr);} 5509de99aefSMatthew G. Knepley else if (id == PETSCFV_CLASSID) {ierr = PetscFVGetSpatialDimension((PetscFV) obj, dim);CHKERRQ(ierr);} 5519de99aefSMatthew G. Knepley else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", 0); 5529de99aefSMatthew G. Knepley } 5532764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5542764a2aaSMatthew G. Knepley } 5552764a2aaSMatthew G. Knepley 5562764a2aaSMatthew G. Knepley #undef __FUNCT__ 5572764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalDimension" 558bc4ae4beSMatthew G. Knepley /*@ 559bc4ae4beSMatthew G. Knepley PetscDSGetTotalDimension - Returns the total size of the approximation space for this system 560bc4ae4beSMatthew G. Knepley 561bc4ae4beSMatthew G. Knepley Not collective 562bc4ae4beSMatthew G. Knepley 563bc4ae4beSMatthew G. Knepley Input Parameter: 564bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 565bc4ae4beSMatthew G. Knepley 566bc4ae4beSMatthew G. Knepley Output Parameter: 567bc4ae4beSMatthew G. Knepley . dim - The total problem dimension 568bc4ae4beSMatthew G. Knepley 569bc4ae4beSMatthew G. Knepley Level: beginner 570bc4ae4beSMatthew G. Knepley 571bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 572bc4ae4beSMatthew G. Knepley @*/ 5732764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalDimension(PetscDS prob, PetscInt *dim) 5742764a2aaSMatthew G. Knepley { 5752764a2aaSMatthew G. Knepley PetscErrorCode ierr; 5762764a2aaSMatthew G. Knepley 5772764a2aaSMatthew G. Knepley PetscFunctionBegin; 5782764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 5792764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 5802764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 5812764a2aaSMatthew G. Knepley *dim = prob->totDim; 5822764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5832764a2aaSMatthew G. Knepley } 5842764a2aaSMatthew G. Knepley 5852764a2aaSMatthew G. Knepley #undef __FUNCT__ 5862764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalBdDimension" 587bc4ae4beSMatthew G. Knepley /*@ 588c3ac4435SMatthew G. Knepley PetscDSGetTotalBdDimension - Returns the total size of the boundary approximation space for this system 589bc4ae4beSMatthew G. Knepley 590bc4ae4beSMatthew G. Knepley Not collective 591bc4ae4beSMatthew G. Knepley 592bc4ae4beSMatthew G. Knepley Input Parameter: 593bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 594bc4ae4beSMatthew G. Knepley 595bc4ae4beSMatthew G. Knepley Output Parameter: 596bc4ae4beSMatthew G. Knepley . dim - The total boundary problem dimension 597bc4ae4beSMatthew G. Knepley 598bc4ae4beSMatthew G. Knepley Level: beginner 599bc4ae4beSMatthew G. Knepley 600bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 601bc4ae4beSMatthew G. Knepley @*/ 6022764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalBdDimension(PetscDS prob, PetscInt *dim) 6032764a2aaSMatthew G. Knepley { 6042764a2aaSMatthew G. Knepley PetscErrorCode ierr; 6052764a2aaSMatthew G. Knepley 6062764a2aaSMatthew G. Knepley PetscFunctionBegin; 6072764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6082764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 6092764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 6102764a2aaSMatthew G. Knepley *dim = prob->totDimBd; 6112764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6122764a2aaSMatthew G. Knepley } 6132764a2aaSMatthew G. Knepley 6142764a2aaSMatthew G. Knepley #undef __FUNCT__ 6152764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalComponents" 616bc4ae4beSMatthew G. Knepley /*@ 617bc4ae4beSMatthew G. Knepley PetscDSGetTotalComponents - Returns the total number of components in this system 618bc4ae4beSMatthew G. Knepley 619bc4ae4beSMatthew G. Knepley Not collective 620bc4ae4beSMatthew G. Knepley 621bc4ae4beSMatthew G. Knepley Input Parameter: 622bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 623bc4ae4beSMatthew G. Knepley 624bc4ae4beSMatthew G. Knepley Output Parameter: 625bc4ae4beSMatthew G. Knepley . dim - The total number of components 626bc4ae4beSMatthew G. Knepley 627bc4ae4beSMatthew G. Knepley Level: beginner 628bc4ae4beSMatthew G. Knepley 629bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 630bc4ae4beSMatthew G. Knepley @*/ 6312764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalComponents(PetscDS prob, PetscInt *Nc) 6322764a2aaSMatthew G. Knepley { 6332764a2aaSMatthew G. Knepley PetscErrorCode ierr; 6342764a2aaSMatthew G. Knepley 6352764a2aaSMatthew G. Knepley PetscFunctionBegin; 6362764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6372764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 6382764a2aaSMatthew G. Knepley PetscValidPointer(Nc, 2); 6392764a2aaSMatthew G. Knepley *Nc = prob->totComp; 6402764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6412764a2aaSMatthew G. Knepley } 6422764a2aaSMatthew G. Knepley 6432764a2aaSMatthew G. Knepley #undef __FUNCT__ 6442764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetDiscretization" 645bc4ae4beSMatthew G. Knepley /*@ 646bc4ae4beSMatthew G. Knepley PetscDSGetDiscretization - Returns the discretization object for the given field 647bc4ae4beSMatthew G. Knepley 648bc4ae4beSMatthew G. Knepley Not collective 649bc4ae4beSMatthew G. Knepley 650bc4ae4beSMatthew G. Knepley Input Parameters: 651bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 652bc4ae4beSMatthew G. Knepley - f - The field number 653bc4ae4beSMatthew G. Knepley 654bc4ae4beSMatthew G. Knepley Output Parameter: 655bc4ae4beSMatthew G. Knepley . disc - The discretization object 656bc4ae4beSMatthew G. Knepley 657bc4ae4beSMatthew G. Knepley Level: beginner 658bc4ae4beSMatthew G. Knepley 659bc4ae4beSMatthew G. Knepley .seealso: PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 660bc4ae4beSMatthew G. Knepley @*/ 6612764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetDiscretization(PetscDS prob, PetscInt f, PetscObject *disc) 6622764a2aaSMatthew G. Knepley { 6632764a2aaSMatthew G. Knepley PetscFunctionBegin; 6642764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6652764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 6662764a2aaSMatthew 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); 6672764a2aaSMatthew G. Knepley *disc = prob->disc[f]; 6682764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6692764a2aaSMatthew G. Knepley } 6702764a2aaSMatthew G. Knepley 6712764a2aaSMatthew G. Knepley #undef __FUNCT__ 6722764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdDiscretization" 673bc4ae4beSMatthew G. Knepley /*@ 674bc4ae4beSMatthew G. Knepley PetscDSGetBdDiscretization - Returns the boundary discretization object for the given field 675bc4ae4beSMatthew G. Knepley 676bc4ae4beSMatthew G. Knepley Not collective 677bc4ae4beSMatthew G. Knepley 678bc4ae4beSMatthew G. Knepley Input Parameters: 679bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 680bc4ae4beSMatthew G. Knepley - f - The field number 681bc4ae4beSMatthew G. Knepley 682bc4ae4beSMatthew G. Knepley Output Parameter: 683bc4ae4beSMatthew G. Knepley . disc - The boundary discretization object 684bc4ae4beSMatthew G. Knepley 685bc4ae4beSMatthew G. Knepley Level: beginner 686bc4ae4beSMatthew G. Knepley 687bc4ae4beSMatthew G. Knepley .seealso: PetscDSSetBdDiscretization(), PetscDSAddBdDiscretization(), PetscDSGetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 688bc4ae4beSMatthew G. Knepley @*/ 6892764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdDiscretization(PetscDS prob, PetscInt f, PetscObject *disc) 6902764a2aaSMatthew G. Knepley { 6912764a2aaSMatthew G. Knepley PetscFunctionBegin; 6922764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6932764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 6942764a2aaSMatthew 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); 6952764a2aaSMatthew G. Knepley *disc = prob->discBd[f]; 6962764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6972764a2aaSMatthew G. Knepley } 6982764a2aaSMatthew G. Knepley 6992764a2aaSMatthew G. Knepley #undef __FUNCT__ 7002764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetDiscretization" 701bc4ae4beSMatthew G. Knepley /*@ 702bc4ae4beSMatthew G. Knepley PetscDSSetDiscretization - Sets the discretization object for the given field 703bc4ae4beSMatthew G. Knepley 704bc4ae4beSMatthew G. Knepley Not collective 705bc4ae4beSMatthew G. Knepley 706bc4ae4beSMatthew G. Knepley Input Parameters: 707bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 708bc4ae4beSMatthew G. Knepley . f - The field number 709bc4ae4beSMatthew G. Knepley - disc - The discretization object 710bc4ae4beSMatthew G. Knepley 711bc4ae4beSMatthew G. Knepley Level: beginner 712bc4ae4beSMatthew G. Knepley 713bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 714bc4ae4beSMatthew G. Knepley @*/ 7152764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetDiscretization(PetscDS prob, PetscInt f, PetscObject disc) 7162764a2aaSMatthew G. Knepley { 7172764a2aaSMatthew G. Knepley PetscErrorCode ierr; 7182764a2aaSMatthew G. Knepley 7192764a2aaSMatthew G. Knepley PetscFunctionBegin; 7202764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7212764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 7222764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 7232764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 7242764a2aaSMatthew G. Knepley if (prob->disc[f]) {ierr = PetscObjectDereference(prob->disc[f]);CHKERRQ(ierr);} 7252764a2aaSMatthew G. Knepley prob->disc[f] = disc; 7262764a2aaSMatthew G. Knepley ierr = PetscObjectReference(disc);CHKERRQ(ierr); 727249df284SMatthew G. Knepley { 728249df284SMatthew G. Knepley PetscClassId id; 729249df284SMatthew G. Knepley 730249df284SMatthew G. Knepley ierr = PetscObjectGetClassId(disc, &id);CHKERRQ(ierr); 731a6cbbb48SMatthew G. Knepley if (id == PETSCFV_CLASSID) { 732a6cbbb48SMatthew G. Knepley prob->implicit[f] = PETSC_FALSE; 733a6cbbb48SMatthew G. Knepley prob->adjacency[f*2+0] = PETSC_TRUE; 734a6cbbb48SMatthew G. Knepley prob->adjacency[f*2+1] = PETSC_FALSE; 735a6cbbb48SMatthew G. Knepley } 736249df284SMatthew G. Knepley } 7372764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7382764a2aaSMatthew G. Knepley } 7392764a2aaSMatthew G. Knepley 7402764a2aaSMatthew G. Knepley #undef __FUNCT__ 7412764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdDiscretization" 742bc4ae4beSMatthew G. Knepley /*@ 743bc4ae4beSMatthew G. Knepley PetscDSSetBdDiscretization - Sets the boundary discretization object for the given field 744bc4ae4beSMatthew G. Knepley 745bc4ae4beSMatthew G. Knepley Not collective 746bc4ae4beSMatthew G. Knepley 747bc4ae4beSMatthew G. Knepley Input Parameters: 748bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 749bc4ae4beSMatthew G. Knepley . f - The field number 750bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object 751bc4ae4beSMatthew G. Knepley 752bc4ae4beSMatthew G. Knepley Level: beginner 753bc4ae4beSMatthew G. Knepley 754bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetBdDiscretization(), PetscDSAddBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 755bc4ae4beSMatthew G. Knepley @*/ 7562764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdDiscretization(PetscDS prob, PetscInt f, PetscObject disc) 7572764a2aaSMatthew G. Knepley { 7582764a2aaSMatthew G. Knepley PetscErrorCode ierr; 7592764a2aaSMatthew G. Knepley 7602764a2aaSMatthew G. Knepley PetscFunctionBegin; 7612764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7622764a2aaSMatthew G. Knepley if (disc) PetscValidPointer(disc, 3); 7632764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 7642764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 7652764a2aaSMatthew G. Knepley if (prob->discBd[f]) {ierr = PetscObjectDereference(prob->discBd[f]);CHKERRQ(ierr);} 7662764a2aaSMatthew G. Knepley prob->discBd[f] = disc; 7672764a2aaSMatthew G. Knepley ierr = PetscObjectReference(disc);CHKERRQ(ierr); 7682764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7692764a2aaSMatthew G. Knepley } 7702764a2aaSMatthew G. Knepley 7712764a2aaSMatthew G. Knepley #undef __FUNCT__ 7722764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSAddDiscretization" 773bc4ae4beSMatthew G. Knepley /*@ 774bc4ae4beSMatthew G. Knepley PetscDSAddDiscretization - Adds a discretization object 775bc4ae4beSMatthew G. Knepley 776bc4ae4beSMatthew G. Knepley Not collective 777bc4ae4beSMatthew G. Knepley 778bc4ae4beSMatthew G. Knepley Input Parameters: 779bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 780bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object 781bc4ae4beSMatthew G. Knepley 782bc4ae4beSMatthew G. Knepley Level: beginner 783bc4ae4beSMatthew G. Knepley 784bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSSetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 785bc4ae4beSMatthew G. Knepley @*/ 7862764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddDiscretization(PetscDS prob, PetscObject disc) 7872764a2aaSMatthew G. Knepley { 7882764a2aaSMatthew G. Knepley PetscErrorCode ierr; 7892764a2aaSMatthew G. Knepley 7902764a2aaSMatthew G. Knepley PetscFunctionBegin; 7912764a2aaSMatthew G. Knepley ierr = PetscDSSetDiscretization(prob, prob->Nf, disc);CHKERRQ(ierr); 7922764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7932764a2aaSMatthew G. Knepley } 7942764a2aaSMatthew G. Knepley 7952764a2aaSMatthew G. Knepley #undef __FUNCT__ 7962764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSAddBdDiscretization" 797bc4ae4beSMatthew G. Knepley /*@ 798bc4ae4beSMatthew G. Knepley PetscDSAddBdDiscretization - Adds a boundary 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: PetscDSGetBdDiscretization(), PetscDSSetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 809bc4ae4beSMatthew G. Knepley @*/ 8102764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddBdDiscretization(PetscDS prob, PetscObject disc) 8112764a2aaSMatthew G. Knepley { 8122764a2aaSMatthew G. Knepley PetscErrorCode ierr; 8132764a2aaSMatthew G. Knepley 8142764a2aaSMatthew G. Knepley PetscFunctionBegin; 8152764a2aaSMatthew G. Knepley ierr = PetscDSSetBdDiscretization(prob, prob->Nf, disc);CHKERRQ(ierr); 8162764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8172764a2aaSMatthew G. Knepley } 8182764a2aaSMatthew G. Knepley 8192764a2aaSMatthew G. Knepley #undef __FUNCT__ 820249df284SMatthew G. Knepley #define __FUNCT__ "PetscDSGetImplicit" 821249df284SMatthew G. Knepley /*@ 822249df284SMatthew G. Knepley PetscDSGetImplicit - Returns the flag for implicit solve for this field. This is just a guide for IMEX 823249df284SMatthew G. Knepley 824249df284SMatthew G. Knepley Not collective 825249df284SMatthew G. Knepley 826249df284SMatthew G. Knepley Input Parameters: 827249df284SMatthew G. Knepley + prob - The PetscDS object 828249df284SMatthew G. Knepley - f - The field number 829249df284SMatthew G. Knepley 830249df284SMatthew G. Knepley Output Parameter: 831249df284SMatthew G. Knepley . implicit - The flag indicating what kind of solve to use for this field 832249df284SMatthew G. Knepley 833249df284SMatthew G. Knepley Level: developer 834249df284SMatthew G. Knepley 835249df284SMatthew G. Knepley .seealso: PetscDSSetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 836249df284SMatthew G. Knepley @*/ 837249df284SMatthew G. Knepley PetscErrorCode PetscDSGetImplicit(PetscDS prob, PetscInt f, PetscBool *implicit) 838249df284SMatthew G. Knepley { 839249df284SMatthew G. Knepley PetscFunctionBegin; 840249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 841249df284SMatthew G. Knepley PetscValidPointer(implicit, 3); 842249df284SMatthew 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); 843249df284SMatthew G. Knepley *implicit = prob->implicit[f]; 844249df284SMatthew G. Knepley PetscFunctionReturn(0); 845249df284SMatthew G. Knepley } 846249df284SMatthew G. Knepley 847249df284SMatthew G. Knepley #undef __FUNCT__ 848249df284SMatthew G. Knepley #define __FUNCT__ "PetscDSSetImplicit" 849249df284SMatthew G. Knepley /*@ 850249df284SMatthew G. Knepley PetscDSSetImplicit - Set the flag for implicit solve for this field. This is just a guide for IMEX 851249df284SMatthew G. Knepley 852249df284SMatthew G. Knepley Not collective 853249df284SMatthew G. Knepley 854249df284SMatthew G. Knepley Input Parameters: 855249df284SMatthew G. Knepley + prob - The PetscDS object 856249df284SMatthew G. Knepley . f - The field number 857249df284SMatthew G. Knepley - implicit - The flag indicating what kind of solve to use for this field 858249df284SMatthew G. Knepley 859249df284SMatthew G. Knepley Level: developer 860249df284SMatthew G. Knepley 861249df284SMatthew G. Knepley .seealso: PetscDSGetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 862249df284SMatthew G. Knepley @*/ 863249df284SMatthew G. Knepley PetscErrorCode PetscDSSetImplicit(PetscDS prob, PetscInt f, PetscBool implicit) 864249df284SMatthew G. Knepley { 865249df284SMatthew G. Knepley PetscFunctionBegin; 866249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 867249df284SMatthew G. Knepley if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf); 868249df284SMatthew G. Knepley prob->implicit[f] = implicit; 869249df284SMatthew G. Knepley PetscFunctionReturn(0); 870249df284SMatthew G. Knepley } 871249df284SMatthew G. Knepley 872249df284SMatthew G. Knepley #undef __FUNCT__ 873a6cbbb48SMatthew G. Knepley #define __FUNCT__ "PetscDSGetAdjacency" 874a6cbbb48SMatthew G. Knepley /*@ 875a6cbbb48SMatthew G. Knepley PetscDSGetAdjacency - Returns the flags for determining variable influence 876a6cbbb48SMatthew G. Knepley 877a6cbbb48SMatthew G. Knepley Not collective 878a6cbbb48SMatthew G. Knepley 879a6cbbb48SMatthew G. Knepley Input Parameters: 880a6cbbb48SMatthew G. Knepley + prob - The PetscDS object 881a6cbbb48SMatthew G. Knepley - f - The field number 882a6cbbb48SMatthew G. Knepley 883a6cbbb48SMatthew G. Knepley Output Parameter: 884a6cbbb48SMatthew G. Knepley + useCone - Flag for variable influence starting with the cone operation 885a6cbbb48SMatthew G. Knepley - useClosure - Flag for variable influence using transitive closure 886a6cbbb48SMatthew G. Knepley 887a6cbbb48SMatthew G. Knepley Note: See the discussion in DMPlexGetAdjacencyUseCone() and DMPlexGetAdjacencyUseClosure() 888a6cbbb48SMatthew G. Knepley 889a6cbbb48SMatthew G. Knepley Level: developer 890a6cbbb48SMatthew G. Knepley 891a6cbbb48SMatthew G. Knepley .seealso: PetscDSSetAdjacency(), DMPlexGetAdjacencyUseCone(), DMPlexGetAdjacencyUseClosure(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 892a6cbbb48SMatthew G. Knepley @*/ 893a6cbbb48SMatthew G. Knepley PetscErrorCode PetscDSGetAdjacency(PetscDS prob, PetscInt f, PetscBool *useCone, PetscBool *useClosure) 894a6cbbb48SMatthew G. Knepley { 895a6cbbb48SMatthew G. Knepley PetscFunctionBegin; 896a6cbbb48SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 897a6cbbb48SMatthew G. Knepley PetscValidPointer(useCone, 3); 898a6cbbb48SMatthew G. Knepley PetscValidPointer(useClosure, 4); 899a6cbbb48SMatthew 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); 900a6cbbb48SMatthew G. Knepley *useCone = prob->adjacency[f*2+0]; 901a6cbbb48SMatthew G. Knepley *useClosure = prob->adjacency[f*2+1]; 902a6cbbb48SMatthew G. Knepley PetscFunctionReturn(0); 903a6cbbb48SMatthew G. Knepley } 904a6cbbb48SMatthew G. Knepley 905a6cbbb48SMatthew G. Knepley #undef __FUNCT__ 906a6cbbb48SMatthew G. Knepley #define __FUNCT__ "PetscDSSetAdjacency" 907a6cbbb48SMatthew G. Knepley /*@ 908a6cbbb48SMatthew G. Knepley PetscDSSetAdjacency - Set the flags for determining variable influence 909a6cbbb48SMatthew G. Knepley 910a6cbbb48SMatthew G. Knepley Not collective 911a6cbbb48SMatthew G. Knepley 912a6cbbb48SMatthew G. Knepley Input Parameters: 913a6cbbb48SMatthew G. Knepley + prob - The PetscDS object 914a6cbbb48SMatthew G. Knepley . f - The field number 915a6cbbb48SMatthew G. Knepley . useCone - Flag for variable influence starting with the cone operation 916a6cbbb48SMatthew G. Knepley - useClosure - Flag for variable influence using transitive closure 917a6cbbb48SMatthew G. Knepley 918a6cbbb48SMatthew G. Knepley Note: See the discussion in DMPlexGetAdjacencyUseCone() and DMPlexGetAdjacencyUseClosure() 919a6cbbb48SMatthew G. Knepley 920a6cbbb48SMatthew G. Knepley Level: developer 921a6cbbb48SMatthew G. Knepley 922a6cbbb48SMatthew G. Knepley .seealso: PetscDSGetAdjacency(), DMPlexGetAdjacencyUseCone(), DMPlexGetAdjacencyUseClosure(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 923a6cbbb48SMatthew G. Knepley @*/ 924a6cbbb48SMatthew G. Knepley PetscErrorCode PetscDSSetAdjacency(PetscDS prob, PetscInt f, PetscBool useCone, PetscBool useClosure) 925a6cbbb48SMatthew G. Knepley { 926a6cbbb48SMatthew G. Knepley PetscFunctionBegin; 927a6cbbb48SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 928a6cbbb48SMatthew 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); 929a6cbbb48SMatthew G. Knepley prob->adjacency[f*2+0] = useCone; 930a6cbbb48SMatthew G. Knepley prob->adjacency[f*2+1] = useClosure; 931a6cbbb48SMatthew G. Knepley PetscFunctionReturn(0); 932a6cbbb48SMatthew G. Knepley } 933a6cbbb48SMatthew G. Knepley 934a6cbbb48SMatthew G. Knepley #undef __FUNCT__ 9352764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetObjective" 9362764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetObjective(PetscDS prob, PetscInt f, 93730b9ff8bSMatthew G. Knepley void (**obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 938194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 939194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 94030b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar obj[])) 9412764a2aaSMatthew G. Knepley { 9422764a2aaSMatthew G. Knepley PetscFunctionBegin; 9432764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 9442764a2aaSMatthew G. Knepley PetscValidPointer(obj, 2); 9452764a2aaSMatthew 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); 9462764a2aaSMatthew G. Knepley *obj = prob->obj[f]; 9472764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9482764a2aaSMatthew G. Knepley } 9492764a2aaSMatthew G. Knepley 9502764a2aaSMatthew G. Knepley #undef __FUNCT__ 9512764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetObjective" 9522764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetObjective(PetscDS prob, PetscInt f, 95330b9ff8bSMatthew G. Knepley void (*obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 954194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 955194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 95630b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar obj[])) 9572764a2aaSMatthew G. Knepley { 9582764a2aaSMatthew G. Knepley PetscErrorCode ierr; 9592764a2aaSMatthew G. Knepley 9602764a2aaSMatthew G. Knepley PetscFunctionBegin; 9612764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 962de716cbcSToby Isaac if (obj) PetscValidFunction(obj, 2); 9632764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 9642764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 9652764a2aaSMatthew G. Knepley prob->obj[f] = obj; 9662764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9672764a2aaSMatthew G. Knepley } 9682764a2aaSMatthew G. Knepley 9692764a2aaSMatthew G. Knepley #undef __FUNCT__ 9702764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetResidual" 971194d53e6SMatthew G. Knepley /*@C 972194d53e6SMatthew G. Knepley PetscDSGetResidual - Get the pointwise residual function for a given test field 973194d53e6SMatthew G. Knepley 974194d53e6SMatthew G. Knepley Not collective 975194d53e6SMatthew G. Knepley 976194d53e6SMatthew G. Knepley Input Parameters: 977194d53e6SMatthew G. Knepley + prob - The PetscDS 978194d53e6SMatthew G. Knepley - f - The test field number 979194d53e6SMatthew G. Knepley 980194d53e6SMatthew G. Knepley Output Parameters: 981194d53e6SMatthew G. Knepley + f0 - integrand for the test function term 982194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 983194d53e6SMatthew G. Knepley 984194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 985194d53e6SMatthew G. Knepley 986194d53e6SMatthew 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) 987194d53e6SMatthew G. Knepley 988194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 989194d53e6SMatthew G. Knepley 99030b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 991194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 992194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 99330b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 994194d53e6SMatthew G. Knepley 995194d53e6SMatthew G. Knepley + dim - the spatial dimension 996194d53e6SMatthew G. Knepley . Nf - the number of fields 997194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 998194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 999194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1000194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1001194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1002194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1003194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1004194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1005194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1006194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1007194d53e6SMatthew G. Knepley . t - current time 1008194d53e6SMatthew G. Knepley . x - coordinates of the current point 1009194d53e6SMatthew G. Knepley - f0 - output values at the current point 1010194d53e6SMatthew G. Knepley 1011194d53e6SMatthew G. Knepley Level: intermediate 1012194d53e6SMatthew G. Knepley 1013194d53e6SMatthew G. Knepley .seealso: PetscDSSetResidual() 1014194d53e6SMatthew G. Knepley @*/ 10152764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetResidual(PetscDS prob, PetscInt f, 101630b9ff8bSMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1017194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1018194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 101930b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar f0[]), 102030b9ff8bSMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1021194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1022194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 102330b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar f1[])) 10242764a2aaSMatthew G. Knepley { 10252764a2aaSMatthew G. Knepley PetscFunctionBegin; 10262764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 10272764a2aaSMatthew 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); 10282764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 3); *f0 = prob->f[f*2+0];} 10292764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 4); *f1 = prob->f[f*2+1];} 10302764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 10312764a2aaSMatthew G. Knepley } 10322764a2aaSMatthew G. Knepley 10332764a2aaSMatthew G. Knepley #undef __FUNCT__ 10342764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetResidual" 1035194d53e6SMatthew G. Knepley /*@C 1036194d53e6SMatthew G. Knepley PetscDSSetResidual - Set the pointwise residual function for a given test field 1037194d53e6SMatthew G. Knepley 1038194d53e6SMatthew G. Knepley Not collective 1039194d53e6SMatthew G. Knepley 1040194d53e6SMatthew G. Knepley Input Parameters: 1041194d53e6SMatthew G. Knepley + prob - The PetscDS 1042194d53e6SMatthew G. Knepley . f - The test field number 1043194d53e6SMatthew G. Knepley . f0 - integrand for the test function term 1044194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 1045194d53e6SMatthew G. Knepley 1046194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1047194d53e6SMatthew G. Knepley 1048194d53e6SMatthew 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) 1049194d53e6SMatthew G. Knepley 1050194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1051194d53e6SMatthew G. Knepley 105230b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1053194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1054194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 105530b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1056194d53e6SMatthew G. Knepley 1057194d53e6SMatthew G. Knepley + dim - the spatial dimension 1058194d53e6SMatthew G. Knepley . Nf - the number of fields 1059194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1060194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1061194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1062194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1063194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1064194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1065194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1066194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1067194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1068194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1069194d53e6SMatthew G. Knepley . t - current time 1070194d53e6SMatthew G. Knepley . x - coordinates of the current point 1071194d53e6SMatthew G. Knepley - f0 - output values at the current point 1072194d53e6SMatthew G. Knepley 1073194d53e6SMatthew G. Knepley Level: intermediate 1074194d53e6SMatthew G. Knepley 1075194d53e6SMatthew G. Knepley .seealso: PetscDSGetResidual() 1076194d53e6SMatthew G. Knepley @*/ 10772764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetResidual(PetscDS prob, PetscInt f, 107830b9ff8bSMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1079194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1080194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 108130b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar f0[]), 108230b9ff8bSMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1083194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1084194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 108530b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar f1[])) 10862764a2aaSMatthew G. Knepley { 10872764a2aaSMatthew G. Knepley PetscErrorCode ierr; 10882764a2aaSMatthew G. Knepley 10892764a2aaSMatthew G. Knepley PetscFunctionBegin; 10902764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1091f866a1d0SMatthew G. Knepley if (f0) PetscValidFunction(f0, 3); 1092f866a1d0SMatthew G. Knepley if (f1) PetscValidFunction(f1, 4); 10932764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 10942764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 10952764a2aaSMatthew G. Knepley prob->f[f*2+0] = f0; 10962764a2aaSMatthew G. Knepley prob->f[f*2+1] = f1; 10972764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 10982764a2aaSMatthew G. Knepley } 10992764a2aaSMatthew G. Knepley 11002764a2aaSMatthew G. Knepley #undef __FUNCT__ 11013e75805dSMatthew G. Knepley #define __FUNCT__ "PetscDSHasJacobian" 11023e75805dSMatthew G. Knepley /*@C 11033e75805dSMatthew G. Knepley PetscDSHasJacobian - Signals that Jacobian functions have been set 11043e75805dSMatthew G. Knepley 11053e75805dSMatthew G. Knepley Not collective 11063e75805dSMatthew G. Knepley 11073e75805dSMatthew G. Knepley Input Parameter: 11083e75805dSMatthew G. Knepley . prob - The PetscDS 11093e75805dSMatthew G. Knepley 11103e75805dSMatthew G. Knepley Output Parameter: 11113e75805dSMatthew G. Knepley . hasJac - flag that pointwise function for the Jacobian has been set 11123e75805dSMatthew G. Knepley 11133e75805dSMatthew G. Knepley Level: intermediate 11143e75805dSMatthew G. Knepley 11153e75805dSMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 11163e75805dSMatthew G. Knepley @*/ 11173e75805dSMatthew G. Knepley PetscErrorCode PetscDSHasJacobian(PetscDS prob, PetscBool *hasJac) 11183e75805dSMatthew G. Knepley { 11193e75805dSMatthew G. Knepley PetscInt f, g, h; 11203e75805dSMatthew G. Knepley 11213e75805dSMatthew G. Knepley PetscFunctionBegin; 11223e75805dSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 11233e75805dSMatthew G. Knepley *hasJac = PETSC_FALSE; 11243e75805dSMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 11253e75805dSMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 11263e75805dSMatthew G. Knepley for (h = 0; h < 4; ++h) { 11273e75805dSMatthew G. Knepley if (prob->g[(f*prob->Nf + g)*4+h]) *hasJac = PETSC_TRUE; 11283e75805dSMatthew G. Knepley } 11293e75805dSMatthew G. Knepley } 11303e75805dSMatthew G. Knepley } 11313e75805dSMatthew G. Knepley PetscFunctionReturn(0); 11323e75805dSMatthew G. Knepley } 11333e75805dSMatthew G. Knepley 11343e75805dSMatthew G. Knepley #undef __FUNCT__ 11352764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetJacobian" 1136194d53e6SMatthew G. Knepley /*@C 1137194d53e6SMatthew G. Knepley PetscDSGetJacobian - Get the pointwise Jacobian function for given test and basis field 1138194d53e6SMatthew G. Knepley 1139194d53e6SMatthew G. Knepley Not collective 1140194d53e6SMatthew G. Knepley 1141194d53e6SMatthew G. Knepley Input Parameters: 1142194d53e6SMatthew G. Knepley + prob - The PetscDS 1143194d53e6SMatthew G. Knepley . f - The test field number 1144194d53e6SMatthew G. Knepley - g - The field number 1145194d53e6SMatthew G. Knepley 1146194d53e6SMatthew G. Knepley Output Parameters: 1147194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 1148194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1149194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1150194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1151194d53e6SMatthew G. Knepley 1152194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1153194d53e6SMatthew G. Knepley 1154194d53e6SMatthew 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 1155194d53e6SMatthew G. Knepley 1156194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1157194d53e6SMatthew G. Knepley 115830b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1159194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1160194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 116130b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1162194d53e6SMatthew G. Knepley 1163194d53e6SMatthew G. Knepley + dim - the spatial dimension 1164194d53e6SMatthew G. Knepley . Nf - the number of fields 1165194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1166194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1167194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1168194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1169194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1170194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1171194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1172194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1173194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1174194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1175194d53e6SMatthew G. Knepley . t - current time 11762aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1177194d53e6SMatthew G. Knepley . x - coordinates of the current point 1178194d53e6SMatthew G. Knepley - g0 - output values at the current point 1179194d53e6SMatthew G. Knepley 1180194d53e6SMatthew G. Knepley Level: intermediate 1181194d53e6SMatthew G. Knepley 1182194d53e6SMatthew G. Knepley .seealso: PetscDSSetJacobian() 1183194d53e6SMatthew G. Knepley @*/ 11842764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetJacobian(PetscDS prob, PetscInt f, PetscInt g, 118530b9ff8bSMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1186194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1187194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 11882aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]), 118930b9ff8bSMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1190194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1191194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 11922aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]), 119330b9ff8bSMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1194194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1195194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 11962aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]), 119730b9ff8bSMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1198194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1199194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 12002aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[])) 12012764a2aaSMatthew G. Knepley { 12022764a2aaSMatthew G. Knepley PetscFunctionBegin; 12032764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 12042764a2aaSMatthew 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); 12052764a2aaSMatthew 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); 12062764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g[(f*prob->Nf + g)*4+0];} 12072764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g[(f*prob->Nf + g)*4+1];} 12082764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g[(f*prob->Nf + g)*4+2];} 12092764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g[(f*prob->Nf + g)*4+3];} 12102764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 12112764a2aaSMatthew G. Knepley } 12122764a2aaSMatthew G. Knepley 12132764a2aaSMatthew G. Knepley #undef __FUNCT__ 12142764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetJacobian" 1215194d53e6SMatthew G. Knepley /*@C 1216194d53e6SMatthew G. Knepley PetscDSSetJacobian - Set the pointwise Jacobian function for given test and basis fields 1217194d53e6SMatthew G. Knepley 1218194d53e6SMatthew G. Knepley Not collective 1219194d53e6SMatthew G. Knepley 1220194d53e6SMatthew G. Knepley Input Parameters: 1221194d53e6SMatthew G. Knepley + prob - The PetscDS 1222194d53e6SMatthew G. Knepley . f - The test field number 1223194d53e6SMatthew G. Knepley . g - The field number 1224194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 1225194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1226194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1227194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1228194d53e6SMatthew G. Knepley 1229194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1230194d53e6SMatthew G. Knepley 1231194d53e6SMatthew 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 1232194d53e6SMatthew G. Knepley 1233194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1234194d53e6SMatthew G. Knepley 123530b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1236194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1237194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 123830b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1239194d53e6SMatthew G. Knepley 1240194d53e6SMatthew G. Knepley + dim - the spatial dimension 1241194d53e6SMatthew G. Knepley . Nf - the number of fields 1242194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1243194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1244194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1245194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1246194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1247194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1248194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1249194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1250194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1251194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1252194d53e6SMatthew G. Knepley . t - current time 12532aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1254194d53e6SMatthew G. Knepley . x - coordinates of the current point 1255194d53e6SMatthew G. Knepley - g0 - output values at the current point 1256194d53e6SMatthew G. Knepley 1257194d53e6SMatthew G. Knepley Level: intermediate 1258194d53e6SMatthew G. Knepley 1259194d53e6SMatthew G. Knepley .seealso: PetscDSGetJacobian() 1260194d53e6SMatthew G. Knepley @*/ 12612764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetJacobian(PetscDS prob, PetscInt f, PetscInt g, 126230b9ff8bSMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1263194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1264194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 126530b9ff8bSMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]), 126630b9ff8bSMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1267194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1268194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 126930b9ff8bSMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]), 127030b9ff8bSMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1271194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1272194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 127330b9ff8bSMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]), 127430b9ff8bSMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1275194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1276194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 127730b9ff8bSMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[])) 12782764a2aaSMatthew G. Knepley { 12792764a2aaSMatthew G. Knepley PetscErrorCode ierr; 12802764a2aaSMatthew G. Knepley 12812764a2aaSMatthew G. Knepley PetscFunctionBegin; 12822764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 12832764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 12842764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 12852764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 12862764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 12872764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 12882764a2aaSMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 12892764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 12902764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+0] = g0; 12912764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+1] = g1; 12922764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+2] = g2; 12932764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+3] = g3; 12942764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 12952764a2aaSMatthew G. Knepley } 12962764a2aaSMatthew G. Knepley 12972764a2aaSMatthew G. Knepley #undef __FUNCT__ 1298475e0ac9SMatthew G. Knepley #define __FUNCT__ "PetscDSHasJacobianPreconditioner" 1299475e0ac9SMatthew G. Knepley /*@C 1300475e0ac9SMatthew G. Knepley PetscDSHasJacobianPreconditioner - Signals that a Jacobian preconditioner matrix has been set 1301475e0ac9SMatthew G. Knepley 1302475e0ac9SMatthew G. Knepley Not collective 1303475e0ac9SMatthew G. Knepley 1304475e0ac9SMatthew G. Knepley Input Parameter: 1305475e0ac9SMatthew G. Knepley . prob - The PetscDS 1306475e0ac9SMatthew G. Knepley 1307475e0ac9SMatthew G. Knepley Output Parameter: 1308475e0ac9SMatthew G. Knepley . hasJacPre - flag that pointwise function for Jacobian preconditioner matrix has been set 1309475e0ac9SMatthew G. Knepley 1310475e0ac9SMatthew G. Knepley Level: intermediate 1311475e0ac9SMatthew G. Knepley 1312475e0ac9SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 1313475e0ac9SMatthew G. Knepley @*/ 1314475e0ac9SMatthew G. Knepley PetscErrorCode PetscDSHasJacobianPreconditioner(PetscDS prob, PetscBool *hasJacPre) 1315475e0ac9SMatthew G. Knepley { 1316475e0ac9SMatthew G. Knepley PetscInt f, g, h; 1317475e0ac9SMatthew G. Knepley 1318475e0ac9SMatthew G. Knepley PetscFunctionBegin; 1319475e0ac9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1320475e0ac9SMatthew G. Knepley *hasJacPre = PETSC_FALSE; 1321475e0ac9SMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 1322475e0ac9SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 1323475e0ac9SMatthew G. Knepley for (h = 0; h < 4; ++h) { 1324475e0ac9SMatthew G. Knepley if (prob->gp[(f*prob->Nf + g)*4+h]) *hasJacPre = PETSC_TRUE; 1325475e0ac9SMatthew G. Knepley } 1326475e0ac9SMatthew G. Knepley } 1327475e0ac9SMatthew G. Knepley } 1328475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1329475e0ac9SMatthew G. Knepley } 1330475e0ac9SMatthew G. Knepley 1331475e0ac9SMatthew G. Knepley #undef __FUNCT__ 1332475e0ac9SMatthew G. Knepley #define __FUNCT__ "PetscDSGetJacobianPreconditioner" 1333475e0ac9SMatthew G. Knepley /*@C 1334475e0ac9SMatthew 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. 1335475e0ac9SMatthew G. Knepley 1336475e0ac9SMatthew G. Knepley Not collective 1337475e0ac9SMatthew G. Knepley 1338475e0ac9SMatthew G. Knepley Input Parameters: 1339475e0ac9SMatthew G. Knepley + prob - The PetscDS 1340475e0ac9SMatthew G. Knepley . f - The test field number 1341475e0ac9SMatthew G. Knepley - g - The field number 1342475e0ac9SMatthew G. Knepley 1343475e0ac9SMatthew G. Knepley Output Parameters: 1344475e0ac9SMatthew G. Knepley + g0 - integrand for the test and basis function term 1345475e0ac9SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1346475e0ac9SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1347475e0ac9SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1348475e0ac9SMatthew G. Knepley 1349475e0ac9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1350475e0ac9SMatthew G. Knepley 1351475e0ac9SMatthew 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 1352475e0ac9SMatthew G. Knepley 1353475e0ac9SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1354475e0ac9SMatthew G. Knepley 1355475e0ac9SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1356475e0ac9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1357475e0ac9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1358475e0ac9SMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1359475e0ac9SMatthew G. Knepley 1360475e0ac9SMatthew G. Knepley + dim - the spatial dimension 1361475e0ac9SMatthew G. Knepley . Nf - the number of fields 1362475e0ac9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1363475e0ac9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1364475e0ac9SMatthew G. Knepley . u - each field evaluated at the current point 1365475e0ac9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1366475e0ac9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1367475e0ac9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1368475e0ac9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1369475e0ac9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1370475e0ac9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1371475e0ac9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1372475e0ac9SMatthew G. Knepley . t - current time 1373475e0ac9SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1374475e0ac9SMatthew G. Knepley . x - coordinates of the current point 1375475e0ac9SMatthew G. Knepley - g0 - output values at the current point 1376475e0ac9SMatthew G. Knepley 1377475e0ac9SMatthew G. Knepley Level: intermediate 1378475e0ac9SMatthew G. Knepley 1379475e0ac9SMatthew G. Knepley .seealso: PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 1380475e0ac9SMatthew G. Knepley @*/ 1381475e0ac9SMatthew G. Knepley PetscErrorCode PetscDSGetJacobianPreconditioner(PetscDS prob, PetscInt f, PetscInt g, 1382475e0ac9SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1383475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1384475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1385475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]), 1386475e0ac9SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1387475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1388475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1389475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]), 1390475e0ac9SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1391475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1392475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1393475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]), 1394475e0ac9SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1395475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1396475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1397475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[])) 1398475e0ac9SMatthew G. Knepley { 1399475e0ac9SMatthew G. Knepley PetscFunctionBegin; 1400475e0ac9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1401475e0ac9SMatthew 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); 1402475e0ac9SMatthew 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); 1403475e0ac9SMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gp[(f*prob->Nf + g)*4+0];} 1404475e0ac9SMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gp[(f*prob->Nf + g)*4+1];} 1405475e0ac9SMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gp[(f*prob->Nf + g)*4+2];} 1406475e0ac9SMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gp[(f*prob->Nf + g)*4+3];} 1407475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1408475e0ac9SMatthew G. Knepley } 1409475e0ac9SMatthew G. Knepley 1410475e0ac9SMatthew G. Knepley #undef __FUNCT__ 1411475e0ac9SMatthew G. Knepley #define __FUNCT__ "PetscDSSetJacobianPreconditioner" 1412475e0ac9SMatthew G. Knepley /*@C 1413475e0ac9SMatthew 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. 1414475e0ac9SMatthew G. Knepley 1415475e0ac9SMatthew G. Knepley Not collective 1416475e0ac9SMatthew G. Knepley 1417475e0ac9SMatthew G. Knepley Input Parameters: 1418475e0ac9SMatthew G. Knepley + prob - The PetscDS 1419475e0ac9SMatthew G. Knepley . f - The test field number 1420475e0ac9SMatthew G. Knepley . g - The field number 1421475e0ac9SMatthew G. Knepley . g0 - integrand for the test and basis function term 1422475e0ac9SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1423475e0ac9SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1424475e0ac9SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1425475e0ac9SMatthew G. Knepley 1426475e0ac9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1427475e0ac9SMatthew G. Knepley 1428475e0ac9SMatthew 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 1429475e0ac9SMatthew G. Knepley 1430475e0ac9SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1431475e0ac9SMatthew G. Knepley 1432475e0ac9SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1433475e0ac9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1434475e0ac9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1435475e0ac9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1436475e0ac9SMatthew G. Knepley 1437475e0ac9SMatthew G. Knepley + dim - the spatial dimension 1438475e0ac9SMatthew G. Knepley . Nf - the number of fields 1439475e0ac9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1440475e0ac9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1441475e0ac9SMatthew G. Knepley . u - each field evaluated at the current point 1442475e0ac9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1443475e0ac9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1444475e0ac9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1445475e0ac9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1446475e0ac9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1447475e0ac9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1448475e0ac9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1449475e0ac9SMatthew G. Knepley . t - current time 1450475e0ac9SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1451475e0ac9SMatthew G. Knepley . x - coordinates of the current point 1452475e0ac9SMatthew G. Knepley - g0 - output values at the current point 1453475e0ac9SMatthew G. Knepley 1454475e0ac9SMatthew G. Knepley Level: intermediate 1455475e0ac9SMatthew G. Knepley 1456475e0ac9SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobian() 1457475e0ac9SMatthew G. Knepley @*/ 1458475e0ac9SMatthew G. Knepley PetscErrorCode PetscDSSetJacobianPreconditioner(PetscDS prob, PetscInt f, PetscInt g, 1459475e0ac9SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1460475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1461475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1462475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]), 1463475e0ac9SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1464475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1465475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1466475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]), 1467475e0ac9SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1468475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1469475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1470475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]), 1471475e0ac9SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1472475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1473475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1474475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[])) 1475475e0ac9SMatthew G. Knepley { 1476475e0ac9SMatthew G. Knepley PetscErrorCode ierr; 1477475e0ac9SMatthew G. Knepley 1478475e0ac9SMatthew G. Knepley PetscFunctionBegin; 1479475e0ac9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1480475e0ac9SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 1481475e0ac9SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 1482475e0ac9SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 1483475e0ac9SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 1484475e0ac9SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 1485475e0ac9SMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 1486475e0ac9SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 1487475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+0] = g0; 1488475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+1] = g1; 1489475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+2] = g2; 1490475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+3] = g3; 1491475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1492475e0ac9SMatthew G. Knepley } 1493475e0ac9SMatthew G. Knepley 1494475e0ac9SMatthew G. Knepley #undef __FUNCT__ 1495b7e05686SMatthew G. Knepley #define __FUNCT__ "PetscDSHasDynamicJacobian" 1496b7e05686SMatthew G. Knepley /*@C 1497b7e05686SMatthew G. Knepley PetscDSHasDynamicJacobian - Signals that a dynamic Jacobian, dF/du_t, has been set 1498b7e05686SMatthew G. Knepley 1499b7e05686SMatthew G. Knepley Not collective 1500b7e05686SMatthew G. Knepley 1501b7e05686SMatthew G. Knepley Input Parameter: 1502b7e05686SMatthew G. Knepley . prob - The PetscDS 1503b7e05686SMatthew G. Knepley 1504b7e05686SMatthew G. Knepley Output Parameter: 1505b7e05686SMatthew G. Knepley . hasDynJac - flag that pointwise function for dynamic Jacobian has been set 1506b7e05686SMatthew G. Knepley 1507b7e05686SMatthew G. Knepley Level: intermediate 1508b7e05686SMatthew G. Knepley 1509b7e05686SMatthew G. Knepley .seealso: PetscDSGetDynamicJacobian(), PetscDSSetDynamicJacobian(), PetscDSGetJacobian() 1510b7e05686SMatthew G. Knepley @*/ 1511b7e05686SMatthew G. Knepley PetscErrorCode PetscDSHasDynamicJacobian(PetscDS prob, PetscBool *hasDynJac) 1512b7e05686SMatthew G. Knepley { 1513b7e05686SMatthew G. Knepley PetscInt f, g, h; 1514b7e05686SMatthew G. Knepley 1515b7e05686SMatthew G. Knepley PetscFunctionBegin; 1516b7e05686SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1517b7e05686SMatthew G. Knepley *hasDynJac = PETSC_FALSE; 1518b7e05686SMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 1519b7e05686SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 1520b7e05686SMatthew G. Knepley for (h = 0; h < 4; ++h) { 1521b7e05686SMatthew G. Knepley if (prob->gt[(f*prob->Nf + g)*4+h]) *hasDynJac = PETSC_TRUE; 1522b7e05686SMatthew G. Knepley } 1523b7e05686SMatthew G. Knepley } 1524b7e05686SMatthew G. Knepley } 1525b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1526b7e05686SMatthew G. Knepley } 1527b7e05686SMatthew G. Knepley 1528b7e05686SMatthew G. Knepley #undef __FUNCT__ 1529b7e05686SMatthew G. Knepley #define __FUNCT__ "PetscDSGetDynamicJacobian" 1530b7e05686SMatthew G. Knepley /*@C 1531b7e05686SMatthew G. Knepley PetscDSGetDynamicJacobian - Get the pointwise dynamic Jacobian, dF/du_t, function for given test and basis field 1532b7e05686SMatthew G. Knepley 1533b7e05686SMatthew G. Knepley Not collective 1534b7e05686SMatthew G. Knepley 1535b7e05686SMatthew G. Knepley Input Parameters: 1536b7e05686SMatthew G. Knepley + prob - The PetscDS 1537b7e05686SMatthew G. Knepley . f - The test field number 1538b7e05686SMatthew G. Knepley - g - The field number 1539b7e05686SMatthew G. Knepley 1540b7e05686SMatthew G. Knepley Output Parameters: 1541b7e05686SMatthew G. Knepley + g0 - integrand for the test and basis function term 1542b7e05686SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1543b7e05686SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1544b7e05686SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1545b7e05686SMatthew G. Knepley 1546b7e05686SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1547b7e05686SMatthew G. Knepley 1548b7e05686SMatthew 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 1549b7e05686SMatthew G. Knepley 1550b7e05686SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1551b7e05686SMatthew G. Knepley 1552b7e05686SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1553b7e05686SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1554b7e05686SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1555b7e05686SMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1556b7e05686SMatthew G. Knepley 1557b7e05686SMatthew G. Knepley + dim - the spatial dimension 1558b7e05686SMatthew G. Knepley . Nf - the number of fields 1559b7e05686SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1560b7e05686SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1561b7e05686SMatthew G. Knepley . u - each field evaluated at the current point 1562b7e05686SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1563b7e05686SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1564b7e05686SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1565b7e05686SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1566b7e05686SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1567b7e05686SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1568b7e05686SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1569b7e05686SMatthew G. Knepley . t - current time 1570b7e05686SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1571b7e05686SMatthew G. Knepley . x - coordinates of the current point 1572b7e05686SMatthew G. Knepley - g0 - output values at the current point 1573b7e05686SMatthew G. Knepley 1574b7e05686SMatthew G. Knepley Level: intermediate 1575b7e05686SMatthew G. Knepley 1576b7e05686SMatthew G. Knepley .seealso: PetscDSSetJacobian() 1577b7e05686SMatthew G. Knepley @*/ 1578b7e05686SMatthew G. Knepley PetscErrorCode PetscDSGetDynamicJacobian(PetscDS prob, PetscInt f, PetscInt g, 1579b7e05686SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1580b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1581b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1582b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]), 1583b7e05686SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1584b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1585b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1586b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]), 1587b7e05686SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1588b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1589b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1590b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]), 1591b7e05686SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1592b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1593b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1594b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[])) 1595b7e05686SMatthew G. Knepley { 1596b7e05686SMatthew G. Knepley PetscFunctionBegin; 1597b7e05686SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1598b7e05686SMatthew 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); 1599b7e05686SMatthew 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); 1600b7e05686SMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gt[(f*prob->Nf + g)*4+0];} 1601b7e05686SMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gt[(f*prob->Nf + g)*4+1];} 1602b7e05686SMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gt[(f*prob->Nf + g)*4+2];} 1603b7e05686SMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gt[(f*prob->Nf + g)*4+3];} 1604b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1605b7e05686SMatthew G. Knepley } 1606b7e05686SMatthew G. Knepley 1607b7e05686SMatthew G. Knepley #undef __FUNCT__ 1608b7e05686SMatthew G. Knepley #define __FUNCT__ "PetscDSSetDynamicJacobian" 1609b7e05686SMatthew G. Knepley /*@C 1610b7e05686SMatthew G. Knepley PetscDSSetDynamicJacobian - Set the pointwise dynamic Jacobian, dF/du_t, function for given test and basis fields 1611b7e05686SMatthew G. Knepley 1612b7e05686SMatthew G. Knepley Not collective 1613b7e05686SMatthew G. Knepley 1614b7e05686SMatthew G. Knepley Input Parameters: 1615b7e05686SMatthew G. Knepley + prob - The PetscDS 1616b7e05686SMatthew G. Knepley . f - The test field number 1617b7e05686SMatthew G. Knepley . g - The field number 1618b7e05686SMatthew G. Knepley . g0 - integrand for the test and basis function term 1619b7e05686SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1620b7e05686SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1621b7e05686SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1622b7e05686SMatthew G. Knepley 1623b7e05686SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1624b7e05686SMatthew G. Knepley 1625b7e05686SMatthew 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 1626b7e05686SMatthew G. Knepley 1627b7e05686SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1628b7e05686SMatthew G. Knepley 1629b7e05686SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1630b7e05686SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1631b7e05686SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1632b7e05686SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1633b7e05686SMatthew G. Knepley 1634b7e05686SMatthew G. Knepley + dim - the spatial dimension 1635b7e05686SMatthew G. Knepley . Nf - the number of fields 1636b7e05686SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1637b7e05686SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1638b7e05686SMatthew G. Knepley . u - each field evaluated at the current point 1639b7e05686SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1640b7e05686SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1641b7e05686SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1642b7e05686SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1643b7e05686SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1644b7e05686SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1645b7e05686SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1646b7e05686SMatthew G. Knepley . t - current time 1647b7e05686SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1648b7e05686SMatthew G. Knepley . x - coordinates of the current point 1649b7e05686SMatthew G. Knepley - g0 - output values at the current point 1650b7e05686SMatthew G. Knepley 1651b7e05686SMatthew G. Knepley Level: intermediate 1652b7e05686SMatthew G. Knepley 1653b7e05686SMatthew G. Knepley .seealso: PetscDSGetJacobian() 1654b7e05686SMatthew G. Knepley @*/ 1655b7e05686SMatthew G. Knepley PetscErrorCode PetscDSSetDynamicJacobian(PetscDS prob, PetscInt f, PetscInt g, 1656b7e05686SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1657b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1658b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1659b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]), 1660b7e05686SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1661b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1662b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1663b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]), 1664b7e05686SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1665b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1666b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1667b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]), 1668b7e05686SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1669b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1670b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1671b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[])) 1672b7e05686SMatthew G. Knepley { 1673b7e05686SMatthew G. Knepley PetscErrorCode ierr; 1674b7e05686SMatthew G. Knepley 1675b7e05686SMatthew G. Knepley PetscFunctionBegin; 1676b7e05686SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1677b7e05686SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 1678b7e05686SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 1679b7e05686SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 1680b7e05686SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 1681b7e05686SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 1682b7e05686SMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 1683b7e05686SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 1684b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+0] = g0; 1685b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+1] = g1; 1686b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+2] = g2; 1687b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+3] = g3; 1688b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1689b7e05686SMatthew G. Knepley } 1690b7e05686SMatthew G. Knepley 1691b7e05686SMatthew G. Knepley #undef __FUNCT__ 16920c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSGetRiemannSolver" 16930c2f2876SMatthew G. Knepley /*@C 16940c2f2876SMatthew G. Knepley PetscDSGetRiemannSolver - Returns the Riemann solver for the given field 16950c2f2876SMatthew G. Knepley 16960c2f2876SMatthew G. Knepley Not collective 16970c2f2876SMatthew G. Knepley 16980c2f2876SMatthew G. Knepley Input Arguments: 16990c2f2876SMatthew G. Knepley + prob - The PetscDS object 17000c2f2876SMatthew G. Knepley - f - The field number 17010c2f2876SMatthew G. Knepley 17020c2f2876SMatthew G. Knepley Output Argument: 17030c2f2876SMatthew G. Knepley . r - Riemann solver 17040c2f2876SMatthew G. Knepley 17050c2f2876SMatthew G. Knepley Calling sequence for r: 17060c2f2876SMatthew G. Knepley 17075db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 17080c2f2876SMatthew G. Knepley 17095db36cf9SMatthew G. Knepley + dim - The spatial dimension 17105db36cf9SMatthew G. Knepley . Nf - The number of fields 17115db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 17120c2f2876SMatthew G. Knepley . n - The normal vector to the interface 17130c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 17140c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 17150c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 17160c2f2876SMatthew G. Knepley - ctx - optional user context 17170c2f2876SMatthew G. Knepley 17180c2f2876SMatthew G. Knepley Level: intermediate 17190c2f2876SMatthew G. Knepley 17200c2f2876SMatthew G. Knepley .seealso: PetscDSSetRiemannSolver() 17210c2f2876SMatthew G. Knepley @*/ 17220c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetRiemannSolver(PetscDS prob, PetscInt f, 17235db36cf9SMatthew G. Knepley void (**r)(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx)) 17240c2f2876SMatthew G. Knepley { 17250c2f2876SMatthew G. Knepley PetscFunctionBegin; 17260c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 17270c2f2876SMatthew 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); 17280c2f2876SMatthew G. Knepley PetscValidPointer(r, 3); 17290c2f2876SMatthew G. Knepley *r = prob->r[f]; 17300c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 17310c2f2876SMatthew G. Knepley } 17320c2f2876SMatthew G. Knepley 17330c2f2876SMatthew G. Knepley #undef __FUNCT__ 17340c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSSetRiemannSolver" 17350c2f2876SMatthew G. Knepley /*@C 17360c2f2876SMatthew G. Knepley PetscDSSetRiemannSolver - Sets the Riemann solver for the given field 17370c2f2876SMatthew G. Knepley 17380c2f2876SMatthew G. Knepley Not collective 17390c2f2876SMatthew G. Knepley 17400c2f2876SMatthew G. Knepley Input Arguments: 17410c2f2876SMatthew G. Knepley + prob - The PetscDS object 17420c2f2876SMatthew G. Knepley . f - The field number 17430c2f2876SMatthew G. Knepley - r - Riemann solver 17440c2f2876SMatthew G. Knepley 17450c2f2876SMatthew G. Knepley Calling sequence for r: 17460c2f2876SMatthew G. Knepley 17475db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 17480c2f2876SMatthew G. Knepley 17495db36cf9SMatthew G. Knepley + dim - The spatial dimension 17505db36cf9SMatthew G. Knepley . Nf - The number of fields 17515db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 17520c2f2876SMatthew G. Knepley . n - The normal vector to the interface 17530c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 17540c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 17550c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 17560c2f2876SMatthew G. Knepley - ctx - optional user context 17570c2f2876SMatthew G. Knepley 17580c2f2876SMatthew G. Knepley Level: intermediate 17590c2f2876SMatthew G. Knepley 17600c2f2876SMatthew G. Knepley .seealso: PetscDSGetRiemannSolver() 17610c2f2876SMatthew G. Knepley @*/ 17620c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetRiemannSolver(PetscDS prob, PetscInt f, 17635db36cf9SMatthew G. Knepley void (*r)(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx)) 17640c2f2876SMatthew G. Knepley { 17650c2f2876SMatthew G. Knepley PetscErrorCode ierr; 17660c2f2876SMatthew G. Knepley 17670c2f2876SMatthew G. Knepley PetscFunctionBegin; 17680c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1769de716cbcSToby Isaac if (r) PetscValidFunction(r, 3); 17700c2f2876SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 17710c2f2876SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 17720c2f2876SMatthew G. Knepley prob->r[f] = r; 17730c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 17740c2f2876SMatthew G. Knepley } 17750c2f2876SMatthew G. Knepley 17760c2f2876SMatthew G. Knepley #undef __FUNCT__ 17770c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSGetContext" 17780c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetContext(PetscDS prob, PetscInt f, void **ctx) 17790c2f2876SMatthew G. Knepley { 17800c2f2876SMatthew G. Knepley PetscFunctionBegin; 17810c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 17820c2f2876SMatthew 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); 17830c2f2876SMatthew G. Knepley PetscValidPointer(ctx, 3); 17840c2f2876SMatthew G. Knepley *ctx = prob->ctx[f]; 17850c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 17860c2f2876SMatthew G. Knepley } 17870c2f2876SMatthew G. Knepley 17880c2f2876SMatthew G. Knepley #undef __FUNCT__ 17890c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSSetContext" 17900c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetContext(PetscDS prob, PetscInt f, void *ctx) 17910c2f2876SMatthew G. Knepley { 17920c2f2876SMatthew G. Knepley PetscErrorCode ierr; 17930c2f2876SMatthew G. Knepley 17940c2f2876SMatthew G. Knepley PetscFunctionBegin; 17950c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 17960c2f2876SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 17970c2f2876SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 17980c2f2876SMatthew G. Knepley prob->ctx[f] = ctx; 17990c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 18000c2f2876SMatthew G. Knepley } 18010c2f2876SMatthew G. Knepley 18020c2f2876SMatthew G. Knepley #undef __FUNCT__ 18032764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdResidual" 1804194d53e6SMatthew G. Knepley /*@C 1805194d53e6SMatthew G. Knepley PetscDSGetBdResidual - Get the pointwise boundary residual function for a given test field 1806194d53e6SMatthew G. Knepley 1807194d53e6SMatthew G. Knepley Not collective 1808194d53e6SMatthew G. Knepley 1809194d53e6SMatthew G. Knepley Input Parameters: 1810194d53e6SMatthew G. Knepley + prob - The PetscDS 1811194d53e6SMatthew G. Knepley - f - The test field number 1812194d53e6SMatthew G. Knepley 1813194d53e6SMatthew G. Knepley Output Parameters: 1814194d53e6SMatthew G. Knepley + f0 - boundary integrand for the test function term 1815194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 1816194d53e6SMatthew G. Knepley 1817194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1818194d53e6SMatthew G. Knepley 1819194d53e6SMatthew 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 1820194d53e6SMatthew G. Knepley 1821194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1822194d53e6SMatthew G. Knepley 182330b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1824194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1825194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 182630b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 1827194d53e6SMatthew G. Knepley 1828194d53e6SMatthew G. Knepley + dim - the spatial dimension 1829194d53e6SMatthew G. Knepley . Nf - the number of fields 1830194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1831194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1832194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1833194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1834194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1835194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1836194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1837194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1838194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1839194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1840194d53e6SMatthew G. Knepley . t - current time 1841194d53e6SMatthew G. Knepley . x - coordinates of the current point 1842194d53e6SMatthew G. Knepley . n - unit normal at the current point 1843194d53e6SMatthew G. Knepley - f0 - output values at the current point 1844194d53e6SMatthew G. Knepley 1845194d53e6SMatthew G. Knepley Level: intermediate 1846194d53e6SMatthew G. Knepley 1847194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdResidual() 1848194d53e6SMatthew G. Knepley @*/ 18492764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdResidual(PetscDS prob, PetscInt f, 185030b9ff8bSMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1851194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1852194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 185330b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]), 185430b9ff8bSMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1855194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1856194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 185730b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f1[])) 18582764a2aaSMatthew G. Knepley { 18592764a2aaSMatthew G. Knepley PetscFunctionBegin; 18602764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 18612764a2aaSMatthew 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); 18622764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 3); *f0 = prob->fBd[f*2+0];} 18632764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 4); *f1 = prob->fBd[f*2+1];} 18642764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 18652764a2aaSMatthew G. Knepley } 18662764a2aaSMatthew G. Knepley 18672764a2aaSMatthew G. Knepley #undef __FUNCT__ 18682764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdResidual" 1869194d53e6SMatthew G. Knepley /*@C 1870194d53e6SMatthew G. Knepley PetscDSSetBdResidual - Get the pointwise boundary residual function for a given test field 1871194d53e6SMatthew G. Knepley 1872194d53e6SMatthew G. Knepley Not collective 1873194d53e6SMatthew G. Knepley 1874194d53e6SMatthew G. Knepley Input Parameters: 1875194d53e6SMatthew G. Knepley + prob - The PetscDS 1876194d53e6SMatthew G. Knepley . f - The test field number 1877194d53e6SMatthew G. Knepley . f0 - boundary integrand for the test function term 1878194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 1879194d53e6SMatthew G. Knepley 1880194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1881194d53e6SMatthew G. Knepley 1882194d53e6SMatthew 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 1883194d53e6SMatthew G. Knepley 1884194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1885194d53e6SMatthew G. Knepley 188630b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1887194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1888194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 188930b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 1890194d53e6SMatthew G. Knepley 1891194d53e6SMatthew G. Knepley + dim - the spatial dimension 1892194d53e6SMatthew G. Knepley . Nf - the number of fields 1893194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1894194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1895194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1896194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1897194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1898194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1899194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1900194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1901194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1902194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1903194d53e6SMatthew G. Knepley . t - current time 1904194d53e6SMatthew G. Knepley . x - coordinates of the current point 1905194d53e6SMatthew G. Knepley . n - unit normal at the current point 1906194d53e6SMatthew G. Knepley - f0 - output values at the current point 1907194d53e6SMatthew G. Knepley 1908194d53e6SMatthew G. Knepley Level: intermediate 1909194d53e6SMatthew G. Knepley 1910194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdResidual() 1911194d53e6SMatthew G. Knepley @*/ 19122764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdResidual(PetscDS prob, PetscInt f, 191330b9ff8bSMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1914194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1915194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 191630b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]), 191730b9ff8bSMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1918194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1919194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 192030b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f1[])) 19212764a2aaSMatthew G. Knepley { 19222764a2aaSMatthew G. Knepley PetscErrorCode ierr; 19232764a2aaSMatthew G. Knepley 19242764a2aaSMatthew G. Knepley PetscFunctionBegin; 19252764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 19262764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 19272764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 19282764a2aaSMatthew G. Knepley if (f0) {PetscValidFunction(f0, 3); prob->fBd[f*2+0] = f0;} 19292764a2aaSMatthew G. Knepley if (f1) {PetscValidFunction(f1, 4); prob->fBd[f*2+1] = f1;} 19302764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 19312764a2aaSMatthew G. Knepley } 19322764a2aaSMatthew G. Knepley 19332764a2aaSMatthew G. Knepley #undef __FUNCT__ 19342764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdJacobian" 1935194d53e6SMatthew G. Knepley /*@C 1936194d53e6SMatthew G. Knepley PetscDSGetBdJacobian - Get the pointwise boundary Jacobian function for given test and basis field 1937194d53e6SMatthew G. Knepley 1938194d53e6SMatthew G. Knepley Not collective 1939194d53e6SMatthew G. Knepley 1940194d53e6SMatthew G. Knepley Input Parameters: 1941194d53e6SMatthew G. Knepley + prob - The PetscDS 1942194d53e6SMatthew G. Knepley . f - The test field number 1943194d53e6SMatthew G. Knepley - g - The field number 1944194d53e6SMatthew G. Knepley 1945194d53e6SMatthew G. Knepley Output Parameters: 1946194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 1947194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1948194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1949194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1950194d53e6SMatthew G. Knepley 1951194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1952194d53e6SMatthew G. Knepley 1953194d53e6SMatthew 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 1954194d53e6SMatthew G. Knepley 1955194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1956194d53e6SMatthew G. Knepley 195730b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1958194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1959194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 196030b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 1961194d53e6SMatthew G. Knepley 1962194d53e6SMatthew G. Knepley + dim - the spatial dimension 1963194d53e6SMatthew G. Knepley . Nf - the number of fields 1964194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1965194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1966194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1967194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1968194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1969194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1970194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1971194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1972194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1973194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1974194d53e6SMatthew G. Knepley . t - current time 19752aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1976194d53e6SMatthew G. Knepley . x - coordinates of the current point 1977194d53e6SMatthew G. Knepley . n - normal at the current point 1978194d53e6SMatthew G. Knepley - g0 - output values at the current point 1979194d53e6SMatthew G. Knepley 1980194d53e6SMatthew G. Knepley Level: intermediate 1981194d53e6SMatthew G. Knepley 1982194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdJacobian() 1983194d53e6SMatthew G. Knepley @*/ 19842764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdJacobian(PetscDS prob, PetscInt f, PetscInt g, 198530b9ff8bSMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1986194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1987194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 19882aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g0[]), 198930b9ff8bSMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1990194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1991194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 19922aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g1[]), 199330b9ff8bSMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1994194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1995194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 19962aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g2[]), 199730b9ff8bSMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1998194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1999194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 20002aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g3[])) 20012764a2aaSMatthew G. Knepley { 20022764a2aaSMatthew G. Knepley PetscFunctionBegin; 20032764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 20042764a2aaSMatthew 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); 20052764a2aaSMatthew 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); 20062764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gBd[(f*prob->Nf + g)*4+0];} 20072764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gBd[(f*prob->Nf + g)*4+1];} 20082764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gBd[(f*prob->Nf + g)*4+2];} 20092764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gBd[(f*prob->Nf + g)*4+3];} 20102764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 20112764a2aaSMatthew G. Knepley } 20122764a2aaSMatthew G. Knepley 20132764a2aaSMatthew G. Knepley #undef __FUNCT__ 20142764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdJacobian" 2015194d53e6SMatthew G. Knepley /*@C 2016194d53e6SMatthew G. Knepley PetscDSSetBdJacobian - Set the pointwise boundary Jacobian function for given test and basis field 2017194d53e6SMatthew G. Knepley 2018194d53e6SMatthew G. Knepley Not collective 2019194d53e6SMatthew G. Knepley 2020194d53e6SMatthew G. Knepley Input Parameters: 2021194d53e6SMatthew G. Knepley + prob - The PetscDS 2022194d53e6SMatthew G. Knepley . f - The test field number 2023194d53e6SMatthew G. Knepley . g - The field number 2024194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 2025194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 2026194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 2027194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 2028194d53e6SMatthew G. Knepley 2029194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 2030194d53e6SMatthew G. Knepley 2031194d53e6SMatthew 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 2032194d53e6SMatthew G. Knepley 2033194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 2034194d53e6SMatthew G. Knepley 203530b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2036194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2037194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 203830b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 2039194d53e6SMatthew G. Knepley 2040194d53e6SMatthew G. Knepley + dim - the spatial dimension 2041194d53e6SMatthew G. Knepley . Nf - the number of fields 2042194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 2043194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 2044194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 2045194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2046194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2047194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2048194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2049194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2050194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2051194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2052194d53e6SMatthew G. Knepley . t - current time 20532aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 2054194d53e6SMatthew G. Knepley . x - coordinates of the current point 2055194d53e6SMatthew G. Knepley . n - normal at the current point 2056194d53e6SMatthew G. Knepley - g0 - output values at the current point 2057194d53e6SMatthew G. Knepley 2058194d53e6SMatthew G. Knepley Level: intermediate 2059194d53e6SMatthew G. Knepley 2060194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdJacobian() 2061194d53e6SMatthew G. Knepley @*/ 20622764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdJacobian(PetscDS prob, PetscInt f, PetscInt g, 206330b9ff8bSMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2064194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2065194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 20662aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g0[]), 206730b9ff8bSMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2068194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2069194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 20702aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g1[]), 207130b9ff8bSMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2072194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2073194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 20742aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g2[]), 207530b9ff8bSMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2076194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2077194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 20782aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g3[])) 20792764a2aaSMatthew G. Knepley { 20802764a2aaSMatthew G. Knepley PetscErrorCode ierr; 20812764a2aaSMatthew G. Knepley 20822764a2aaSMatthew G. Knepley PetscFunctionBegin; 20832764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 20842764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 20852764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 20862764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 20872764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 20882764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 20892764a2aaSMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 20902764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 20912764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+0] = g0; 20922764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+1] = g1; 20932764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+2] = g2; 20942764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+3] = g3; 20952764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 20962764a2aaSMatthew G. Knepley } 20972764a2aaSMatthew G. Knepley 20982764a2aaSMatthew G. Knepley #undef __FUNCT__ 20994cd1e086SMatthew G. Knepley #define __FUNCT__ "PetscDSGetFieldIndex" 21004cd1e086SMatthew G. Knepley /*@ 21014cd1e086SMatthew G. Knepley PetscDSGetFieldIndex - Returns the index of the given field 21024cd1e086SMatthew G. Knepley 21034cd1e086SMatthew G. Knepley Not collective 21044cd1e086SMatthew G. Knepley 21054cd1e086SMatthew G. Knepley Input Parameters: 21064cd1e086SMatthew G. Knepley + prob - The PetscDS object 21074cd1e086SMatthew G. Knepley - disc - The discretization object 21084cd1e086SMatthew G. Knepley 21094cd1e086SMatthew G. Knepley Output Parameter: 21104cd1e086SMatthew G. Knepley . f - The field number 21114cd1e086SMatthew G. Knepley 21124cd1e086SMatthew G. Knepley Level: beginner 21134cd1e086SMatthew G. Knepley 21144cd1e086SMatthew G. Knepley .seealso: PetscGetDiscretization(), PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 21154cd1e086SMatthew G. Knepley @*/ 21164cd1e086SMatthew G. Knepley PetscErrorCode PetscDSGetFieldIndex(PetscDS prob, PetscObject disc, PetscInt *f) 21174cd1e086SMatthew G. Knepley { 21184cd1e086SMatthew G. Knepley PetscInt g; 21194cd1e086SMatthew G. Knepley 21204cd1e086SMatthew G. Knepley PetscFunctionBegin; 21214cd1e086SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 21224cd1e086SMatthew G. Knepley PetscValidPointer(f, 3); 21234cd1e086SMatthew G. Knepley *f = -1; 21244cd1e086SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) {if (disc == prob->disc[g]) break;} 21254cd1e086SMatthew G. Knepley if (g == prob->Nf) SETERRQ(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Field not found in PetscDS."); 21264cd1e086SMatthew G. Knepley *f = g; 21274cd1e086SMatthew G. Knepley PetscFunctionReturn(0); 21284cd1e086SMatthew G. Knepley } 21294cd1e086SMatthew G. Knepley 21304cd1e086SMatthew G. Knepley #undef __FUNCT__ 21314cd1e086SMatthew G. Knepley #define __FUNCT__ "PetscDSGetFieldSize" 21324cd1e086SMatthew G. Knepley /*@ 21334cd1e086SMatthew G. Knepley PetscDSGetFieldSize - Returns the size of the given field in the full space basis 21344cd1e086SMatthew G. Knepley 21354cd1e086SMatthew G. Knepley Not collective 21364cd1e086SMatthew G. Knepley 21374cd1e086SMatthew G. Knepley Input Parameters: 21384cd1e086SMatthew G. Knepley + prob - The PetscDS object 21394cd1e086SMatthew G. Knepley - f - The field number 21404cd1e086SMatthew G. Knepley 21414cd1e086SMatthew G. Knepley Output Parameter: 21424cd1e086SMatthew G. Knepley . size - The size 21434cd1e086SMatthew G. Knepley 21444cd1e086SMatthew G. Knepley Level: beginner 21454cd1e086SMatthew G. Knepley 21464cd1e086SMatthew G. Knepley .seealso: PetscDSGetFieldOffset(), PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 21474cd1e086SMatthew G. Knepley @*/ 21484cd1e086SMatthew G. Knepley PetscErrorCode PetscDSGetFieldSize(PetscDS prob, PetscInt f, PetscInt *size) 21494cd1e086SMatthew G. Knepley { 21504cd1e086SMatthew G. Knepley PetscClassId id; 21514cd1e086SMatthew G. Knepley PetscInt Nb, Nc; 21524cd1e086SMatthew G. Knepley PetscErrorCode ierr; 21534cd1e086SMatthew G. Knepley 21544cd1e086SMatthew G. Knepley PetscFunctionBegin; 21554cd1e086SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 21564cd1e086SMatthew G. Knepley PetscValidPointer(size, 3); 21574cd1e086SMatthew 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); 21584cd1e086SMatthew G. Knepley *size = 0; 21594cd1e086SMatthew G. Knepley ierr = PetscObjectGetClassId(prob->disc[f], &id);CHKERRQ(ierr); 21604cd1e086SMatthew G. Knepley if (id == PETSCFE_CLASSID) { 21614cd1e086SMatthew G. Knepley PetscFE fe = (PetscFE) prob->disc[f]; 21624cd1e086SMatthew G. Knepley 21634cd1e086SMatthew G. Knepley ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr); 21644cd1e086SMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 21654cd1e086SMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 21664cd1e086SMatthew G. Knepley PetscFV fv = (PetscFV) prob->disc[f]; 21674cd1e086SMatthew G. Knepley 21684cd1e086SMatthew G. Knepley Nb = 1; 21694cd1e086SMatthew G. Knepley ierr = PetscFVGetNumComponents(fv, &Nc);CHKERRQ(ierr); 21704cd1e086SMatthew G. Knepley } else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", f); 21714cd1e086SMatthew G. Knepley *size = Nb*Nc; 21724cd1e086SMatthew G. Knepley PetscFunctionReturn(0); 21734cd1e086SMatthew G. Knepley } 21744cd1e086SMatthew G. Knepley 21754cd1e086SMatthew G. Knepley #undef __FUNCT__ 21762764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetFieldOffset" 2177bc4ae4beSMatthew G. Knepley /*@ 2178bc4ae4beSMatthew G. Knepley PetscDSGetFieldOffset - Returns the offset of the given field in the full space basis 2179bc4ae4beSMatthew G. Knepley 2180bc4ae4beSMatthew G. Knepley Not collective 2181bc4ae4beSMatthew G. Knepley 2182bc4ae4beSMatthew G. Knepley Input Parameters: 2183bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 2184bc4ae4beSMatthew G. Knepley - f - The field number 2185bc4ae4beSMatthew G. Knepley 2186bc4ae4beSMatthew G. Knepley Output Parameter: 2187bc4ae4beSMatthew G. Knepley . off - The offset 2188bc4ae4beSMatthew G. Knepley 2189bc4ae4beSMatthew G. Knepley Level: beginner 2190bc4ae4beSMatthew G. Knepley 21914cd1e086SMatthew G. Knepley .seealso: PetscDSGetFieldSize(), PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 2192bc4ae4beSMatthew G. Knepley @*/ 21932764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetFieldOffset(PetscDS prob, PetscInt f, PetscInt *off) 21942764a2aaSMatthew G. Knepley { 21954cd1e086SMatthew G. Knepley PetscInt size, g; 21962764a2aaSMatthew G. Knepley PetscErrorCode ierr; 21972764a2aaSMatthew G. Knepley 21982764a2aaSMatthew G. Knepley PetscFunctionBegin; 21992764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 22002764a2aaSMatthew G. Knepley PetscValidPointer(off, 3); 22012764a2aaSMatthew 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); 22022764a2aaSMatthew G. Knepley *off = 0; 22032764a2aaSMatthew G. Knepley for (g = 0; g < f; ++g) { 22044cd1e086SMatthew G. Knepley ierr = PetscDSGetFieldSize(prob, g, &size);CHKERRQ(ierr); 22054cd1e086SMatthew G. Knepley *off += size; 22062764a2aaSMatthew G. Knepley } 22072764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 22082764a2aaSMatthew G. Knepley } 22092764a2aaSMatthew G. Knepley 22102764a2aaSMatthew G. Knepley #undef __FUNCT__ 22112764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdFieldOffset" 2212bc4ae4beSMatthew G. Knepley /*@ 2213c3ac4435SMatthew G. Knepley PetscDSGetBdFieldOffset - Returns the offset of the given field in the full space boundary basis 2214bc4ae4beSMatthew G. Knepley 2215bc4ae4beSMatthew G. Knepley Not collective 2216bc4ae4beSMatthew G. Knepley 2217bc4ae4beSMatthew G. Knepley Input Parameters: 2218bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 2219bc4ae4beSMatthew G. Knepley - f - The field number 2220bc4ae4beSMatthew G. Knepley 2221bc4ae4beSMatthew G. Knepley Output Parameter: 2222bc4ae4beSMatthew G. Knepley . off - The boundary offset 2223bc4ae4beSMatthew G. Knepley 2224bc4ae4beSMatthew G. Knepley Level: beginner 2225bc4ae4beSMatthew G. Knepley 2226bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 2227bc4ae4beSMatthew G. Knepley @*/ 22282764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdFieldOffset(PetscDS prob, PetscInt f, PetscInt *off) 22292764a2aaSMatthew G. Knepley { 22302764a2aaSMatthew G. Knepley PetscInt g; 22312764a2aaSMatthew G. Knepley PetscErrorCode ierr; 22322764a2aaSMatthew G. Knepley 22332764a2aaSMatthew G. Knepley PetscFunctionBegin; 22342764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 22352764a2aaSMatthew G. Knepley PetscValidPointer(off, 3); 22362764a2aaSMatthew 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); 22372764a2aaSMatthew G. Knepley *off = 0; 22382764a2aaSMatthew G. Knepley for (g = 0; g < f; ++g) { 22392764a2aaSMatthew G. Knepley PetscFE fe = (PetscFE) prob->discBd[g]; 22402764a2aaSMatthew G. Knepley PetscInt Nb, Nc; 22412764a2aaSMatthew G. Knepley 22422764a2aaSMatthew G. Knepley ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr); 22432764a2aaSMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 22442764a2aaSMatthew G. Knepley *off += Nb*Nc; 22456ce16762SMatthew G. Knepley } 22466ce16762SMatthew G. Knepley PetscFunctionReturn(0); 22476ce16762SMatthew G. Knepley } 22486ce16762SMatthew G. Knepley 22496ce16762SMatthew G. Knepley #undef __FUNCT__ 22506ce16762SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentOffset" 22516ce16762SMatthew G. Knepley /*@ 22526ce16762SMatthew G. Knepley PetscDSGetComponentOffset - Returns the offset of the given field on an evaluation point 22536ce16762SMatthew G. Knepley 22546ce16762SMatthew G. Knepley Not collective 22556ce16762SMatthew G. Knepley 22566ce16762SMatthew G. Knepley Input Parameters: 22576ce16762SMatthew G. Knepley + prob - The PetscDS object 22586ce16762SMatthew G. Knepley - f - The field number 22596ce16762SMatthew G. Knepley 22606ce16762SMatthew G. Knepley Output Parameter: 22616ce16762SMatthew G. Knepley . off - The offset 22626ce16762SMatthew G. Knepley 22636ce16762SMatthew G. Knepley Level: beginner 22646ce16762SMatthew G. Knepley 22656ce16762SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 22666ce16762SMatthew G. Knepley @*/ 22676ce16762SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffset(PetscDS prob, PetscInt f, PetscInt *off) 22686ce16762SMatthew G. Knepley { 22696ce16762SMatthew G. Knepley PetscInt g; 22706ce16762SMatthew G. Knepley PetscErrorCode ierr; 22716ce16762SMatthew G. Knepley 22726ce16762SMatthew G. Knepley PetscFunctionBegin; 22736ce16762SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 22746ce16762SMatthew G. Knepley PetscValidPointer(off, 3); 22756ce16762SMatthew 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); 22766ce16762SMatthew G. Knepley *off = 0; 22776ce16762SMatthew G. Knepley for (g = 0; g < f; ++g) { 22786ce16762SMatthew G. Knepley PetscFE fe = (PetscFE) prob->disc[g]; 22796ce16762SMatthew G. Knepley PetscInt Nc; 22806ce16762SMatthew G. Knepley 22816ce16762SMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 22826ce16762SMatthew G. Knepley *off += Nc; 22832764a2aaSMatthew G. Knepley } 22842764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 22852764a2aaSMatthew G. Knepley } 22862764a2aaSMatthew G. Knepley 22872764a2aaSMatthew G. Knepley #undef __FUNCT__ 2288194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentOffsets" 2289194d53e6SMatthew G. Knepley /*@ 2290194d53e6SMatthew G. Knepley PetscDSGetComponentOffsets - Returns the offset of each field on an evaluation point 2291194d53e6SMatthew G. Knepley 2292194d53e6SMatthew G. Knepley Not collective 2293194d53e6SMatthew G. Knepley 2294194d53e6SMatthew G. Knepley Input Parameter: 2295194d53e6SMatthew G. Knepley . prob - The PetscDS object 2296194d53e6SMatthew G. Knepley 2297194d53e6SMatthew G. Knepley Output Parameter: 2298194d53e6SMatthew G. Knepley . offsets - The offsets 2299194d53e6SMatthew G. Knepley 2300194d53e6SMatthew G. Knepley Level: beginner 2301194d53e6SMatthew G. Knepley 2302194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 2303194d53e6SMatthew G. Knepley @*/ 2304194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffsets(PetscDS prob, PetscInt *offsets[]) 2305194d53e6SMatthew G. Knepley { 2306194d53e6SMatthew G. Knepley PetscFunctionBegin; 2307194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2308194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 2309194d53e6SMatthew G. Knepley *offsets = prob->off; 2310194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 2311194d53e6SMatthew G. Knepley } 2312194d53e6SMatthew G. Knepley 2313194d53e6SMatthew G. Knepley #undef __FUNCT__ 2314194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentDerivativeOffsets" 2315194d53e6SMatthew G. Knepley /*@ 2316194d53e6SMatthew G. Knepley PetscDSGetComponentDerivativeOffsets - Returns the offset of each field derivative on an evaluation point 2317194d53e6SMatthew G. Knepley 2318194d53e6SMatthew G. Knepley Not collective 2319194d53e6SMatthew G. Knepley 2320194d53e6SMatthew G. Knepley Input Parameter: 2321194d53e6SMatthew G. Knepley . prob - The PetscDS object 2322194d53e6SMatthew G. Knepley 2323194d53e6SMatthew G. Knepley Output Parameter: 2324194d53e6SMatthew G. Knepley . offsets - The offsets 2325194d53e6SMatthew G. Knepley 2326194d53e6SMatthew G. Knepley Level: beginner 2327194d53e6SMatthew G. Knepley 2328194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 2329194d53e6SMatthew G. Knepley @*/ 2330194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentDerivativeOffsets(PetscDS prob, PetscInt *offsets[]) 2331194d53e6SMatthew G. Knepley { 2332194d53e6SMatthew G. Knepley PetscFunctionBegin; 2333194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2334194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 2335194d53e6SMatthew G. Knepley *offsets = prob->offDer; 2336194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 2337194d53e6SMatthew G. Knepley } 2338194d53e6SMatthew G. Knepley 2339194d53e6SMatthew G. Knepley #undef __FUNCT__ 2340194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentBdOffsets" 2341194d53e6SMatthew G. Knepley /*@ 2342194d53e6SMatthew G. Knepley PetscDSGetComponentBdOffsets - Returns the offset of each field on a boundary evaluation point 2343194d53e6SMatthew G. Knepley 2344194d53e6SMatthew G. Knepley Not collective 2345194d53e6SMatthew G. Knepley 2346194d53e6SMatthew G. Knepley Input Parameter: 2347194d53e6SMatthew G. Knepley . prob - The PetscDS object 2348194d53e6SMatthew G. Knepley 2349194d53e6SMatthew G. Knepley Output Parameter: 2350194d53e6SMatthew G. Knepley . offsets - The offsets 2351194d53e6SMatthew G. Knepley 2352194d53e6SMatthew G. Knepley Level: beginner 2353194d53e6SMatthew G. Knepley 2354194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 2355194d53e6SMatthew G. Knepley @*/ 2356194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentBdOffsets(PetscDS prob, PetscInt *offsets[]) 2357194d53e6SMatthew G. Knepley { 2358194d53e6SMatthew G. Knepley PetscFunctionBegin; 2359194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2360194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 2361194d53e6SMatthew G. Knepley *offsets = prob->offBd; 2362194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 2363194d53e6SMatthew G. Knepley } 2364194d53e6SMatthew G. Knepley 2365194d53e6SMatthew G. Knepley #undef __FUNCT__ 2366194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentBdDerivativeOffsets" 2367194d53e6SMatthew G. Knepley /*@ 2368194d53e6SMatthew G. Knepley PetscDSGetComponentBdDerivativeOffsets - Returns the offset of each field derivative on a boundary evaluation point 2369194d53e6SMatthew G. Knepley 2370194d53e6SMatthew G. Knepley Not collective 2371194d53e6SMatthew G. Knepley 2372194d53e6SMatthew G. Knepley Input Parameter: 2373194d53e6SMatthew G. Knepley . prob - The PetscDS object 2374194d53e6SMatthew G. Knepley 2375194d53e6SMatthew G. Knepley Output Parameter: 2376194d53e6SMatthew G. Knepley . offsets - The offsets 2377194d53e6SMatthew G. Knepley 2378194d53e6SMatthew G. Knepley Level: beginner 2379194d53e6SMatthew G. Knepley 2380194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 2381194d53e6SMatthew G. Knepley @*/ 2382194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentBdDerivativeOffsets(PetscDS prob, PetscInt *offsets[]) 2383194d53e6SMatthew G. Knepley { 2384194d53e6SMatthew G. Knepley PetscFunctionBegin; 2385194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2386194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 2387194d53e6SMatthew G. Knepley *offsets = prob->offDerBd; 2388194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 2389194d53e6SMatthew G. Knepley } 2390194d53e6SMatthew G. Knepley 2391194d53e6SMatthew G. Knepley #undef __FUNCT__ 23922764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTabulation" 239368c9edb9SMatthew G. Knepley /*@C 239468c9edb9SMatthew G. Knepley PetscDSGetTabulation - Return the basis tabulation at quadrature points for the volume discretization 239568c9edb9SMatthew G. Knepley 239668c9edb9SMatthew G. Knepley Not collective 239768c9edb9SMatthew G. Knepley 239868c9edb9SMatthew G. Knepley Input Parameter: 239968c9edb9SMatthew G. Knepley . prob - The PetscDS object 240068c9edb9SMatthew G. Knepley 240168c9edb9SMatthew G. Knepley Output Parameters: 240268c9edb9SMatthew G. Knepley + basis - The basis function tabulation at quadrature points 240368c9edb9SMatthew G. Knepley - basisDer - The basis function derivative tabulation at quadrature points 240468c9edb9SMatthew G. Knepley 240568c9edb9SMatthew G. Knepley Level: intermediate 240668c9edb9SMatthew G. Knepley 240768c9edb9SMatthew G. Knepley .seealso: PetscDSGetBdTabulation(), PetscDSCreate() 240868c9edb9SMatthew G. Knepley @*/ 24092764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTabulation(PetscDS prob, PetscReal ***basis, PetscReal ***basisDer) 24102764a2aaSMatthew G. Knepley { 24112764a2aaSMatthew G. Knepley PetscErrorCode ierr; 24122764a2aaSMatthew G. Knepley 24132764a2aaSMatthew G. Knepley PetscFunctionBegin; 24142764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 24152764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 24162764a2aaSMatthew G. Knepley if (basis) {PetscValidPointer(basis, 2); *basis = prob->basis;} 24172764a2aaSMatthew G. Knepley if (basisDer) {PetscValidPointer(basisDer, 3); *basisDer = prob->basisDer;} 24182764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 24192764a2aaSMatthew G. Knepley } 24202764a2aaSMatthew G. Knepley 24212764a2aaSMatthew G. Knepley #undef __FUNCT__ 24222764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdTabulation" 242368c9edb9SMatthew G. Knepley /*@C 242468c9edb9SMatthew G. Knepley PetscDSGetBdTabulation - Return the basis tabulation at quadrature points for the boundary discretization 242568c9edb9SMatthew G. Knepley 242668c9edb9SMatthew G. Knepley Not collective 242768c9edb9SMatthew G. Knepley 242868c9edb9SMatthew G. Knepley Input Parameter: 242968c9edb9SMatthew G. Knepley . prob - The PetscDS object 243068c9edb9SMatthew G. Knepley 243168c9edb9SMatthew G. Knepley Output Parameters: 243268c9edb9SMatthew G. Knepley + basis - The basis function tabulation at quadrature points 243368c9edb9SMatthew G. Knepley - basisDer - The basis function derivative tabulation at quadrature points 243468c9edb9SMatthew G. Knepley 243568c9edb9SMatthew G. Knepley Level: intermediate 243668c9edb9SMatthew G. Knepley 243768c9edb9SMatthew G. Knepley .seealso: PetscDSGetTabulation(), PetscDSCreate() 243868c9edb9SMatthew G. Knepley @*/ 24392764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdTabulation(PetscDS prob, PetscReal ***basis, PetscReal ***basisDer) 24402764a2aaSMatthew G. Knepley { 24412764a2aaSMatthew G. Knepley PetscErrorCode ierr; 24422764a2aaSMatthew G. Knepley 24432764a2aaSMatthew G. Knepley PetscFunctionBegin; 24442764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 24452764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 24462764a2aaSMatthew G. Knepley if (basis) {PetscValidPointer(basis, 2); *basis = prob->basisBd;} 24472764a2aaSMatthew G. Knepley if (basisDer) {PetscValidPointer(basisDer, 3); *basisDer = prob->basisDerBd;} 24482764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 24492764a2aaSMatthew G. Knepley } 24502764a2aaSMatthew G. Knepley 24512764a2aaSMatthew G. Knepley #undef __FUNCT__ 24522764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetEvaluationArrays" 24532764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetEvaluationArrays(PetscDS prob, PetscScalar **u, PetscScalar **u_t, PetscScalar **u_x) 24542764a2aaSMatthew G. Knepley { 24552764a2aaSMatthew G. Knepley PetscErrorCode ierr; 24562764a2aaSMatthew G. Knepley 24572764a2aaSMatthew G. Knepley PetscFunctionBegin; 24582764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 24592764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 24602764a2aaSMatthew G. Knepley if (u) {PetscValidPointer(u, 2); *u = prob->u;} 24612764a2aaSMatthew G. Knepley if (u_t) {PetscValidPointer(u_t, 3); *u_t = prob->u_t;} 24622764a2aaSMatthew G. Knepley if (u_x) {PetscValidPointer(u_x, 4); *u_x = prob->u_x;} 24632764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 24642764a2aaSMatthew G. Knepley } 24652764a2aaSMatthew G. Knepley 24662764a2aaSMatthew G. Knepley #undef __FUNCT__ 24672764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetWeakFormArrays" 24682764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetWeakFormArrays(PetscDS prob, PetscScalar **f0, PetscScalar **f1, PetscScalar **g0, PetscScalar **g1, PetscScalar **g2, PetscScalar **g3) 24692764a2aaSMatthew G. Knepley { 24702764a2aaSMatthew G. Knepley PetscErrorCode ierr; 24712764a2aaSMatthew G. Knepley 24722764a2aaSMatthew G. Knepley PetscFunctionBegin; 24732764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 24742764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 24752764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 2); *f0 = prob->f0;} 24762764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 3); *f1 = prob->f1;} 24772764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g0;} 24782764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g1;} 24792764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g2;} 24802764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g3;} 24812764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 24822764a2aaSMatthew G. Knepley } 24832764a2aaSMatthew G. Knepley 24842764a2aaSMatthew G. Knepley #undef __FUNCT__ 24852764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetRefCoordArrays" 24862764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetRefCoordArrays(PetscDS prob, PetscReal **x, PetscScalar **refSpaceDer) 24872764a2aaSMatthew G. Knepley { 24882764a2aaSMatthew G. Knepley PetscErrorCode ierr; 24892764a2aaSMatthew G. Knepley 24902764a2aaSMatthew G. Knepley PetscFunctionBegin; 24912764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 24922764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 24932764a2aaSMatthew G. Knepley if (x) {PetscValidPointer(x, 2); *x = prob->x;} 24942764a2aaSMatthew G. Knepley if (refSpaceDer) {PetscValidPointer(refSpaceDer, 3); *refSpaceDer = prob->refSpaceDer;} 24952764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 24962764a2aaSMatthew G. Knepley } 24972764a2aaSMatthew G. Knepley 24982764a2aaSMatthew G. Knepley #undef __FUNCT__ 2499*58ebd649SToby Isaac #define __FUNCT__ "PetscDSAddBoundary" 2500*58ebd649SToby Isaac /*@C 2501*58ebd649SToby Isaac PetscDSAddBoundary - Add a boundary condition to the model 2502*58ebd649SToby Isaac 2503*58ebd649SToby Isaac Input Parameters: 2504*58ebd649SToby Isaac + ds - The PetscDS object 2505*58ebd649SToby Isaac . isEssential - Flag for an essential (Dirichlet) condition, as opposed to a natural (Neumann) condition 2506*58ebd649SToby Isaac . name - The BC name 2507*58ebd649SToby Isaac . labelname - The label defining constrained points 2508*58ebd649SToby Isaac . field - The field to constrain 2509*58ebd649SToby Isaac . numcomps - The number of constrained field components 2510*58ebd649SToby Isaac . comps - An array of constrained component numbers 2511*58ebd649SToby Isaac . bcFunc - A pointwise function giving boundary values 2512*58ebd649SToby Isaac . numids - The number of DMLabel ids for constrained points 2513*58ebd649SToby Isaac . ids - An array of ids for constrained points 2514*58ebd649SToby Isaac - ctx - An optional user context for bcFunc 2515*58ebd649SToby Isaac 2516*58ebd649SToby Isaac Options Database Keys: 2517*58ebd649SToby Isaac + -bc_<boundary name> <num> - Overrides the boundary ids 2518*58ebd649SToby Isaac - -bc_<boundary name>_comp <num> - Overrides the boundary components 2519*58ebd649SToby Isaac 2520*58ebd649SToby Isaac Level: developer 2521*58ebd649SToby Isaac 2522*58ebd649SToby Isaac .seealso: PetscDSGetBoundary() 2523*58ebd649SToby Isaac @*/ 2524*58ebd649SToby 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) 2525*58ebd649SToby Isaac { 2526*58ebd649SToby Isaac DSBoundary b; 2527*58ebd649SToby Isaac PetscErrorCode ierr; 2528*58ebd649SToby Isaac 2529*58ebd649SToby Isaac PetscFunctionBegin; 2530*58ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 2531*58ebd649SToby Isaac ierr = PetscNew(&b);CHKERRQ(ierr); 2532*58ebd649SToby Isaac ierr = PetscStrallocpy(name, (char **) &b->name);CHKERRQ(ierr); 2533*58ebd649SToby Isaac ierr = PetscStrallocpy(labelname, (char **) &b->labelname);CHKERRQ(ierr); 2534*58ebd649SToby Isaac ierr = PetscMalloc1(numcomps, &b->comps);CHKERRQ(ierr); 2535*58ebd649SToby Isaac if (numcomps) {ierr = PetscMemcpy(b->comps, comps, numcomps*sizeof(PetscInt));CHKERRQ(ierr);} 2536*58ebd649SToby Isaac ierr = PetscMalloc1(numids, &b->ids);CHKERRQ(ierr); 2537*58ebd649SToby Isaac if (numids) {ierr = PetscMemcpy(b->ids, ids, numids*sizeof(PetscInt));CHKERRQ(ierr);} 2538*58ebd649SToby Isaac b->essential = isEssential; 2539*58ebd649SToby Isaac b->field = field; 2540*58ebd649SToby Isaac b->numcomps = numcomps; 2541*58ebd649SToby Isaac b->func = bcFunc; 2542*58ebd649SToby Isaac b->numids = numids; 2543*58ebd649SToby Isaac b->ctx = ctx; 2544*58ebd649SToby Isaac b->next = ds->boundary; 2545*58ebd649SToby Isaac ds->boundary = b; 2546*58ebd649SToby Isaac PetscFunctionReturn(0); 2547*58ebd649SToby Isaac } 2548*58ebd649SToby Isaac 2549*58ebd649SToby Isaac #undef __FUNCT__ 2550*58ebd649SToby Isaac #define __FUNCT__ "PetscDSGetNumBoundary" 2551*58ebd649SToby Isaac /*@ 2552*58ebd649SToby Isaac PetscDSGetNumBoundary - Get the number of registered BC 2553*58ebd649SToby Isaac 2554*58ebd649SToby Isaac Input Parameters: 2555*58ebd649SToby Isaac . ds - The PetscDS object 2556*58ebd649SToby Isaac 2557*58ebd649SToby Isaac Output Parameters: 2558*58ebd649SToby Isaac . numBd - The number of BC 2559*58ebd649SToby Isaac 2560*58ebd649SToby Isaac Level: intermediate 2561*58ebd649SToby Isaac 2562*58ebd649SToby Isaac .seealso: PetscDSAddBoundary(), PetscDSGetBoundary() 2563*58ebd649SToby Isaac @*/ 2564*58ebd649SToby Isaac PetscErrorCode PetscDSGetNumBoundary(PetscDS ds, PetscInt *numBd) 2565*58ebd649SToby Isaac { 2566*58ebd649SToby Isaac DSBoundary b = ds->boundary; 2567*58ebd649SToby Isaac 2568*58ebd649SToby Isaac PetscFunctionBegin; 2569*58ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 2570*58ebd649SToby Isaac PetscValidPointer(numBd, 2); 2571*58ebd649SToby Isaac *numBd = 0; 2572*58ebd649SToby Isaac while (b) {++(*numBd); b = b->next;} 2573*58ebd649SToby Isaac PetscFunctionReturn(0); 2574*58ebd649SToby Isaac } 2575*58ebd649SToby Isaac 2576*58ebd649SToby Isaac #undef __FUNCT__ 2577*58ebd649SToby Isaac #define __FUNCT__ "PetscDSGetBoundary" 2578*58ebd649SToby Isaac /*@C 2579*58ebd649SToby Isaac PetscDSGetBoundary - Add a boundary condition to the model 2580*58ebd649SToby Isaac 2581*58ebd649SToby Isaac Input Parameters: 2582*58ebd649SToby Isaac + ds - The PetscDS object 2583*58ebd649SToby Isaac - bd - The BC number 2584*58ebd649SToby Isaac 2585*58ebd649SToby Isaac Output Parameters: 2586*58ebd649SToby Isaac + isEssential - Flag for an essential (Dirichlet) condition, as opposed to a natural (Neumann) condition 2587*58ebd649SToby Isaac . name - The BC name 2588*58ebd649SToby Isaac . labelname - The label defining constrained points 2589*58ebd649SToby Isaac . field - The field to constrain 2590*58ebd649SToby Isaac . numcomps - The number of constrained field components 2591*58ebd649SToby Isaac . comps - An array of constrained component numbers 2592*58ebd649SToby Isaac . bcFunc - A pointwise function giving boundary values 2593*58ebd649SToby Isaac . numids - The number of DMLabel ids for constrained points 2594*58ebd649SToby Isaac . ids - An array of ids for constrained points 2595*58ebd649SToby Isaac - ctx - An optional user context for bcFunc 2596*58ebd649SToby Isaac 2597*58ebd649SToby Isaac Options Database Keys: 2598*58ebd649SToby Isaac + -bc_<boundary name> <num> - Overrides the boundary ids 2599*58ebd649SToby Isaac - -bc_<boundary name>_comp <num> - Overrides the boundary components 2600*58ebd649SToby Isaac 2601*58ebd649SToby Isaac Level: developer 2602*58ebd649SToby Isaac 2603*58ebd649SToby Isaac .seealso: PetscDSAddBoundary() 2604*58ebd649SToby Isaac @*/ 2605*58ebd649SToby 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) 2606*58ebd649SToby Isaac { 2607*58ebd649SToby Isaac DSBoundary b = ds->boundary; 2608*58ebd649SToby Isaac PetscInt n = 0; 2609*58ebd649SToby Isaac 2610*58ebd649SToby Isaac PetscFunctionBegin; 2611*58ebd649SToby Isaac PetscValidHeaderSpecific(ds, PETSCDS_CLASSID, 1); 2612*58ebd649SToby Isaac while (b) { 2613*58ebd649SToby Isaac if (n == bd) break; 2614*58ebd649SToby Isaac b = b->next; 2615*58ebd649SToby Isaac ++n; 2616*58ebd649SToby Isaac } 2617*58ebd649SToby Isaac if (!b) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Boundary %d is not in [0, %d)", bd, n); 2618*58ebd649SToby Isaac if (isEssential) { 2619*58ebd649SToby Isaac PetscValidPointer(isEssential, 3); 2620*58ebd649SToby Isaac *isEssential = b->essential; 2621*58ebd649SToby Isaac } 2622*58ebd649SToby Isaac if (name) { 2623*58ebd649SToby Isaac PetscValidPointer(name, 4); 2624*58ebd649SToby Isaac *name = b->name; 2625*58ebd649SToby Isaac } 2626*58ebd649SToby Isaac if (labelname) { 2627*58ebd649SToby Isaac PetscValidPointer(labelname, 5); 2628*58ebd649SToby Isaac *labelname = b->labelname; 2629*58ebd649SToby Isaac } 2630*58ebd649SToby Isaac if (field) { 2631*58ebd649SToby Isaac PetscValidPointer(field, 6); 2632*58ebd649SToby Isaac *field = b->field; 2633*58ebd649SToby Isaac } 2634*58ebd649SToby Isaac if (numcomps) { 2635*58ebd649SToby Isaac PetscValidPointer(numcomps, 7); 2636*58ebd649SToby Isaac *numcomps = b->numcomps; 2637*58ebd649SToby Isaac } 2638*58ebd649SToby Isaac if (comps) { 2639*58ebd649SToby Isaac PetscValidPointer(comps, 8); 2640*58ebd649SToby Isaac *comps = b->comps; 2641*58ebd649SToby Isaac } 2642*58ebd649SToby Isaac if (func) { 2643*58ebd649SToby Isaac PetscValidPointer(func, 9); 2644*58ebd649SToby Isaac *func = b->func; 2645*58ebd649SToby Isaac } 2646*58ebd649SToby Isaac if (numids) { 2647*58ebd649SToby Isaac PetscValidPointer(numids, 10); 2648*58ebd649SToby Isaac *numids = b->numids; 2649*58ebd649SToby Isaac } 2650*58ebd649SToby Isaac if (ids) { 2651*58ebd649SToby Isaac PetscValidPointer(ids, 11); 2652*58ebd649SToby Isaac *ids = b->ids; 2653*58ebd649SToby Isaac } 2654*58ebd649SToby Isaac if (ctx) { 2655*58ebd649SToby Isaac PetscValidPointer(ctx, 12); 2656*58ebd649SToby Isaac *ctx = b->ctx; 2657*58ebd649SToby Isaac } 2658*58ebd649SToby Isaac PetscFunctionReturn(0); 2659*58ebd649SToby Isaac } 2660*58ebd649SToby Isaac 2661*58ebd649SToby Isaac #undef __FUNCT__ 2662da51fcedSMatthew G. Knepley #define __FUNCT__ "PetscDSCopyEquations" 2663da51fcedSMatthew G. Knepley /*@ 2664da51fcedSMatthew G. Knepley PetscDSCopyEquations - Copy all pointwise function pointers to the new problem 2665da51fcedSMatthew G. Knepley 2666da51fcedSMatthew G. Knepley Not collective 2667da51fcedSMatthew G. Knepley 2668da51fcedSMatthew G. Knepley Input Parameter: 2669da51fcedSMatthew G. Knepley . prob - The PetscDS object 2670da51fcedSMatthew G. Knepley 2671da51fcedSMatthew G. Knepley Output Parameter: 2672da51fcedSMatthew G. Knepley . newprob - The PetscDS copy 2673da51fcedSMatthew G. Knepley 2674da51fcedSMatthew G. Knepley Level: intermediate 2675da51fcedSMatthew G. Knepley 2676da51fcedSMatthew G. Knepley .seealso: PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 2677da51fcedSMatthew G. Knepley @*/ 2678da51fcedSMatthew G. Knepley PetscErrorCode PetscDSCopyEquations(PetscDS prob, PetscDS newprob) 2679da51fcedSMatthew G. Knepley { 2680da51fcedSMatthew G. Knepley PetscInt Nf, Ng, f, g; 2681da51fcedSMatthew G. Knepley PetscErrorCode ierr; 2682da51fcedSMatthew G. Knepley 2683da51fcedSMatthew G. Knepley PetscFunctionBegin; 2684da51fcedSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2685da51fcedSMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 2); 2686da51fcedSMatthew G. Knepley ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr); 2687da51fcedSMatthew G. Knepley ierr = PetscDSGetNumFields(newprob, &Ng);CHKERRQ(ierr); 2688da51fcedSMatthew G. Knepley if (Nf != Ng) SETERRQ2(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_SIZ, "Number of fields must match %D != %D", Nf, Ng);CHKERRQ(ierr); 2689da51fcedSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 2690da51fcedSMatthew G. Knepley PetscPointFunc obj; 2691da51fcedSMatthew G. Knepley PetscPointFunc f0, f1; 2692da51fcedSMatthew G. Knepley PetscPointJac g0, g1, g2, g3; 2693da51fcedSMatthew G. Knepley PetscBdPointFunc f0Bd, f1Bd; 2694da51fcedSMatthew G. Knepley PetscBdPointJac g0Bd, g1Bd, g2Bd, g3Bd; 2695da51fcedSMatthew G. Knepley PetscRiemannFunc r; 2696da51fcedSMatthew G. Knepley 2697da51fcedSMatthew G. Knepley ierr = PetscDSGetObjective(prob, f, &obj);CHKERRQ(ierr); 2698da51fcedSMatthew G. Knepley ierr = PetscDSGetResidual(prob, f, &f0, &f1);CHKERRQ(ierr); 2699da51fcedSMatthew G. Knepley ierr = PetscDSGetBdResidual(prob, f, &f0Bd, &f1Bd);CHKERRQ(ierr); 2700da51fcedSMatthew G. Knepley ierr = PetscDSGetRiemannSolver(prob, f, &r);CHKERRQ(ierr); 2701da51fcedSMatthew G. Knepley ierr = PetscDSSetObjective(newprob, f, obj);CHKERRQ(ierr); 2702da51fcedSMatthew G. Knepley ierr = PetscDSSetResidual(newprob, f, f0, f1);CHKERRQ(ierr); 2703da51fcedSMatthew G. Knepley ierr = PetscDSSetBdResidual(newprob, f, f0Bd, f1Bd);CHKERRQ(ierr); 2704da51fcedSMatthew G. Knepley ierr = PetscDSSetRiemannSolver(newprob, f, r);CHKERRQ(ierr); 2705da51fcedSMatthew G. Knepley for (g = 0; g < Nf; ++g) { 2706da51fcedSMatthew G. Knepley ierr = PetscDSGetJacobian(prob, f, g, &g0, &g1, &g2, &g3);CHKERRQ(ierr); 2707da51fcedSMatthew G. Knepley ierr = PetscDSGetBdJacobian(prob, f, g, &g0Bd, &g1Bd, &g2Bd, &g3Bd);CHKERRQ(ierr); 2708da51fcedSMatthew G. Knepley ierr = PetscDSSetJacobian(newprob, f, g, g0, g1, g2, g3);CHKERRQ(ierr); 2709da51fcedSMatthew G. Knepley ierr = PetscDSSetBdJacobian(newprob, f, g, g0Bd, g1Bd, g2Bd, g3Bd);CHKERRQ(ierr); 2710da51fcedSMatthew G. Knepley } 2711da51fcedSMatthew G. Knepley } 2712da51fcedSMatthew G. Knepley PetscFunctionReturn(0); 2713da51fcedSMatthew G. Knepley } 2714da51fcedSMatthew G. Knepley 2715da51fcedSMatthew G. Knepley #undef __FUNCT__ 27162764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroy_Basic" 2717bc4ae4beSMatthew G. Knepley static PetscErrorCode PetscDSDestroy_Basic(PetscDS prob) 27182764a2aaSMatthew G. Knepley { 27192764a2aaSMatthew G. Knepley PetscFunctionBegin; 27202764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 27212764a2aaSMatthew G. Knepley } 27222764a2aaSMatthew G. Knepley 27232764a2aaSMatthew G. Knepley #undef __FUNCT__ 27242764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSInitialize_Basic" 2725bc4ae4beSMatthew G. Knepley static PetscErrorCode PetscDSInitialize_Basic(PetscDS prob) 27262764a2aaSMatthew G. Knepley { 27272764a2aaSMatthew G. Knepley PetscFunctionBegin; 27282764a2aaSMatthew G. Knepley prob->ops->setfromoptions = NULL; 27292764a2aaSMatthew G. Knepley prob->ops->setup = NULL; 27302764a2aaSMatthew G. Knepley prob->ops->view = NULL; 27312764a2aaSMatthew G. Knepley prob->ops->destroy = PetscDSDestroy_Basic; 27322764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 27332764a2aaSMatthew G. Knepley } 27342764a2aaSMatthew G. Knepley 27352764a2aaSMatthew G. Knepley /*MC 27362764a2aaSMatthew G. Knepley PETSCDSBASIC = "basic" - A discrete system with pointwise residual and boundary residual functions 27372764a2aaSMatthew G. Knepley 27382764a2aaSMatthew G. Knepley Level: intermediate 27392764a2aaSMatthew G. Knepley 27402764a2aaSMatthew G. Knepley .seealso: PetscDSType, PetscDSCreate(), PetscDSSetType() 27412764a2aaSMatthew G. Knepley M*/ 27422764a2aaSMatthew G. Knepley 27432764a2aaSMatthew G. Knepley #undef __FUNCT__ 27442764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSCreate_Basic" 27452764a2aaSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscDSCreate_Basic(PetscDS prob) 27462764a2aaSMatthew G. Knepley { 27472764a2aaSMatthew G. Knepley PetscDS_Basic *b; 27482764a2aaSMatthew G. Knepley PetscErrorCode ierr; 27492764a2aaSMatthew G. Knepley 27502764a2aaSMatthew G. Knepley PetscFunctionBegin; 27512764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCSPACE_CLASSID, 1); 27522764a2aaSMatthew G. Knepley ierr = PetscNewLog(prob, &b);CHKERRQ(ierr); 27532764a2aaSMatthew G. Knepley prob->data = b; 27542764a2aaSMatthew G. Knepley 27552764a2aaSMatthew G. Knepley ierr = PetscDSInitialize_Basic(prob);CHKERRQ(ierr); 27562764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 27572764a2aaSMatthew G. Knepley } 2758