12764a2aaSMatthew G. Knepley #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);} 157*249df284SMatthew G. Knepley if (prob->implicit[f]) {ierr = PetscViewerASCIIPrintf(viewer, " (implicit)");CHKERRQ(ierr);} 158*249df284SMatthew G. Knepley else {ierr = PetscViewerASCIIPrintf(viewer, " (explicit)");CHKERRQ(ierr);} 1597d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "\n");CHKERRQ(ierr); 1607d8a60eaSMatthew G. Knepley if (format == PETSC_VIEWER_ASCII_INFO_DETAIL) { 1617d8a60eaSMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEView((PetscFE) obj, viewer);CHKERRQ(ierr);} 1627d8a60eaSMatthew G. Knepley else if (id == PETSCFV_CLASSID) {ierr = PetscFVView((PetscFV) obj, viewer);CHKERRQ(ierr);} 1637d8a60eaSMatthew G. Knepley } 1647d8a60eaSMatthew G. Knepley } 1657d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); 1667d8a60eaSMatthew G. Knepley PetscFunctionReturn(0); 1677d8a60eaSMatthew G. Knepley } 1687d8a60eaSMatthew G. Knepley 1697d8a60eaSMatthew G. Knepley #undef __FUNCT__ 1702764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSView" 1712764a2aaSMatthew G. Knepley /*@C 1722764a2aaSMatthew G. Knepley PetscDSView - Views a PetscDS 1732764a2aaSMatthew G. Knepley 1742764a2aaSMatthew G. Knepley Collective on PetscDS 1752764a2aaSMatthew G. Knepley 1762764a2aaSMatthew G. Knepley Input Parameter: 1772764a2aaSMatthew G. Knepley + prob - the PetscDS object to view 1782764a2aaSMatthew G. Knepley - v - the viewer 1792764a2aaSMatthew G. Knepley 1802764a2aaSMatthew G. Knepley Level: developer 1812764a2aaSMatthew G. Knepley 1822764a2aaSMatthew G. Knepley .seealso PetscDSDestroy() 1832764a2aaSMatthew G. Knepley @*/ 1842764a2aaSMatthew G. Knepley PetscErrorCode PetscDSView(PetscDS prob, PetscViewer v) 1852764a2aaSMatthew G. Knepley { 1867d8a60eaSMatthew G. Knepley PetscBool iascii; 1872764a2aaSMatthew G. Knepley PetscErrorCode ierr; 1882764a2aaSMatthew G. Knepley 1892764a2aaSMatthew G. Knepley PetscFunctionBegin; 1902764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1912764a2aaSMatthew G. Knepley if (!v) {ierr = PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject) prob), &v);CHKERRQ(ierr);} 1927d8a60eaSMatthew G. Knepley else {PetscValidHeaderSpecific(v, PETSC_VIEWER_CLASSID, 2);} 1937d8a60eaSMatthew G. Knepley ierr = PetscObjectTypeCompare((PetscObject) v, PETSCVIEWERASCII, &iascii);CHKERRQ(ierr); 1947d8a60eaSMatthew G. Knepley if (iascii) {ierr = PetscDSView_Ascii(prob, v);CHKERRQ(ierr);} 1952764a2aaSMatthew G. Knepley if (prob->ops->view) {ierr = (*prob->ops->view)(prob, v);CHKERRQ(ierr);} 1962764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 1972764a2aaSMatthew G. Knepley } 1982764a2aaSMatthew G. Knepley 1992764a2aaSMatthew G. Knepley #undef __FUNCT__ 2002764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSViewFromOptions" 2012764a2aaSMatthew G. Knepley /* 2022764a2aaSMatthew G. Knepley PetscDSViewFromOptions - Processes command line options to determine if/how a PetscDS is to be viewed. 2032764a2aaSMatthew G. Knepley 2042764a2aaSMatthew G. Knepley Collective on PetscDS 2052764a2aaSMatthew G. Knepley 2062764a2aaSMatthew G. Knepley Input Parameters: 2072764a2aaSMatthew G. Knepley + prob - the PetscDS 2082764a2aaSMatthew G. Knepley . prefix - prefix to use for viewing, or NULL to use prefix of 'rnd' 2092764a2aaSMatthew G. Knepley - optionname - option to activate viewing 2102764a2aaSMatthew G. Knepley 2112764a2aaSMatthew G. Knepley Level: intermediate 2122764a2aaSMatthew G. Knepley 2132764a2aaSMatthew G. Knepley .keywords: PetscDS, view, options, database 2142764a2aaSMatthew G. Knepley .seealso: VecViewFromOptions(), MatViewFromOptions() 2152764a2aaSMatthew G. Knepley */ 2162764a2aaSMatthew G. Knepley PetscErrorCode PetscDSViewFromOptions(PetscDS prob, const char prefix[], const char optionname[]) 2172764a2aaSMatthew G. Knepley { 2182764a2aaSMatthew G. Knepley PetscViewer viewer; 2192764a2aaSMatthew G. Knepley PetscViewerFormat format; 2202764a2aaSMatthew G. Knepley PetscBool flg; 2212764a2aaSMatthew G. Knepley PetscErrorCode ierr; 2222764a2aaSMatthew G. Knepley 2232764a2aaSMatthew G. Knepley PetscFunctionBegin; 2242764a2aaSMatthew G. Knepley if (prefix) {ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject) prob), prefix, optionname, &viewer, &format, &flg);CHKERRQ(ierr);} 2252764a2aaSMatthew G. Knepley else {ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject) prob), ((PetscObject) prob)->prefix, optionname, &viewer, &format, &flg);CHKERRQ(ierr);} 2262764a2aaSMatthew G. Knepley if (flg) { 2272764a2aaSMatthew G. Knepley ierr = PetscViewerPushFormat(viewer, format);CHKERRQ(ierr); 2282764a2aaSMatthew G. Knepley ierr = PetscDSView(prob, viewer);CHKERRQ(ierr); 2292764a2aaSMatthew G. Knepley ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); 2302764a2aaSMatthew G. Knepley ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); 2312764a2aaSMatthew G. Knepley } 2322764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 2332764a2aaSMatthew G. Knepley } 2342764a2aaSMatthew G. Knepley 2352764a2aaSMatthew G. Knepley #undef __FUNCT__ 2362764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetFromOptions" 2372764a2aaSMatthew G. Knepley /*@ 2382764a2aaSMatthew G. Knepley PetscDSSetFromOptions - sets parameters in a PetscDS from the options database 2392764a2aaSMatthew G. Knepley 2402764a2aaSMatthew G. Knepley Collective on PetscDS 2412764a2aaSMatthew G. Knepley 2422764a2aaSMatthew G. Knepley Input Parameter: 2432764a2aaSMatthew G. Knepley . prob - the PetscDS object to set options for 2442764a2aaSMatthew G. Knepley 2452764a2aaSMatthew G. Knepley Options Database: 2462764a2aaSMatthew G. Knepley 2472764a2aaSMatthew G. Knepley Level: developer 2482764a2aaSMatthew G. Knepley 2492764a2aaSMatthew G. Knepley .seealso PetscDSView() 2502764a2aaSMatthew G. Knepley @*/ 2512764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetFromOptions(PetscDS prob) 2522764a2aaSMatthew G. Knepley { 2532764a2aaSMatthew G. Knepley const char *defaultType; 2542764a2aaSMatthew G. Knepley char name[256]; 2552764a2aaSMatthew G. Knepley PetscBool flg; 2562764a2aaSMatthew G. Knepley PetscErrorCode ierr; 2572764a2aaSMatthew G. Knepley 2582764a2aaSMatthew G. Knepley PetscFunctionBegin; 2592764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2602764a2aaSMatthew G. Knepley if (!((PetscObject) prob)->type_name) { 2612764a2aaSMatthew G. Knepley defaultType = PETSCDSBASIC; 2622764a2aaSMatthew G. Knepley } else { 2632764a2aaSMatthew G. Knepley defaultType = ((PetscObject) prob)->type_name; 2642764a2aaSMatthew G. Knepley } 2650f51fdf8SToby Isaac ierr = PetscDSRegisterAll();CHKERRQ(ierr); 2662764a2aaSMatthew G. Knepley 2672764a2aaSMatthew G. Knepley ierr = PetscObjectOptionsBegin((PetscObject) prob);CHKERRQ(ierr); 2682764a2aaSMatthew G. Knepley ierr = PetscOptionsFList("-petscds_type", "Discrete System", "PetscDSSetType", PetscDSList, defaultType, name, 256, &flg);CHKERRQ(ierr); 2692764a2aaSMatthew G. Knepley if (flg) { 2702764a2aaSMatthew G. Knepley ierr = PetscDSSetType(prob, name);CHKERRQ(ierr); 2712764a2aaSMatthew G. Knepley } else if (!((PetscObject) prob)->type_name) { 2722764a2aaSMatthew G. Knepley ierr = PetscDSSetType(prob, defaultType);CHKERRQ(ierr); 2732764a2aaSMatthew G. Knepley } 2742764a2aaSMatthew G. Knepley if (prob->ops->setfromoptions) {ierr = (*prob->ops->setfromoptions)(prob);CHKERRQ(ierr);} 2752764a2aaSMatthew G. Knepley /* process any options handlers added with PetscObjectAddOptionsHandler() */ 2762764a2aaSMatthew G. Knepley ierr = PetscObjectProcessOptionsHandlers((PetscObject) prob);CHKERRQ(ierr); 2772764a2aaSMatthew G. Knepley ierr = PetscOptionsEnd();CHKERRQ(ierr); 2782764a2aaSMatthew G. Knepley ierr = PetscDSViewFromOptions(prob, NULL, "-petscds_view");CHKERRQ(ierr); 2792764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 2802764a2aaSMatthew G. Knepley } 2812764a2aaSMatthew G. Knepley 2822764a2aaSMatthew G. Knepley #undef __FUNCT__ 2832764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetUp" 2842764a2aaSMatthew G. Knepley /*@C 2852764a2aaSMatthew G. Knepley PetscDSSetUp - Construct data structures for the PetscDS 2862764a2aaSMatthew G. Knepley 2872764a2aaSMatthew G. Knepley Collective on PetscDS 2882764a2aaSMatthew G. Knepley 2892764a2aaSMatthew G. Knepley Input Parameter: 2902764a2aaSMatthew G. Knepley . prob - the PetscDS object to setup 2912764a2aaSMatthew G. Knepley 2922764a2aaSMatthew G. Knepley Level: developer 2932764a2aaSMatthew G. Knepley 2942764a2aaSMatthew G. Knepley .seealso PetscDSView(), PetscDSDestroy() 2952764a2aaSMatthew G. Knepley @*/ 2962764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetUp(PetscDS prob) 2972764a2aaSMatthew G. Knepley { 2982764a2aaSMatthew G. Knepley const PetscInt Nf = prob->Nf; 2992764a2aaSMatthew G. Knepley PetscInt dim, work, NcMax = 0, NqMax = 0, f; 3002764a2aaSMatthew G. Knepley PetscErrorCode ierr; 3012764a2aaSMatthew G. Knepley 3022764a2aaSMatthew G. Knepley PetscFunctionBegin; 3032764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3042764a2aaSMatthew G. Knepley if (prob->setup) PetscFunctionReturn(0); 3052764a2aaSMatthew G. Knepley /* Calculate sizes */ 3062764a2aaSMatthew G. Knepley ierr = PetscDSGetSpatialDimension(prob, &dim);CHKERRQ(ierr); 3072764a2aaSMatthew G. Knepley prob->totDim = prob->totDimBd = prob->totComp = 0; 3082764a2aaSMatthew G. Knepley ierr = PetscMalloc4(Nf,&prob->basis,Nf,&prob->basisDer,Nf,&prob->basisBd,Nf,&prob->basisDerBd);CHKERRQ(ierr); 3092764a2aaSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 3102764a2aaSMatthew G. Knepley PetscFE feBd = (PetscFE) prob->discBd[f]; 3119de99aefSMatthew G. Knepley PetscObject obj; 3129de99aefSMatthew G. Knepley PetscClassId id; 3132764a2aaSMatthew G. Knepley PetscQuadrature q; 3149de99aefSMatthew G. Knepley PetscInt Nq = 0, Nb, Nc; 3152764a2aaSMatthew G. Knepley 3169de99aefSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr); 3179de99aefSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 3189de99aefSMatthew G. Knepley if (id == PETSCFE_CLASSID) { 3199de99aefSMatthew G. Knepley PetscFE fe = (PetscFE) obj; 3209de99aefSMatthew G. Knepley 3212764a2aaSMatthew G. Knepley ierr = PetscFEGetQuadrature(fe, &q);CHKERRQ(ierr); 3222764a2aaSMatthew G. Knepley ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr); 3232764a2aaSMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 3242764a2aaSMatthew G. Knepley ierr = PetscFEGetDefaultTabulation(fe, &prob->basis[f], &prob->basisDer[f], NULL);CHKERRQ(ierr); 3259de99aefSMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 3269de99aefSMatthew G. Knepley PetscFV fv = (PetscFV) obj; 3279de99aefSMatthew G. Knepley 3289de99aefSMatthew G. Knepley ierr = PetscFVGetQuadrature(fv, &q);CHKERRQ(ierr); 3299de99aefSMatthew G. Knepley Nb = 1; 3309de99aefSMatthew G. Knepley ierr = PetscFVGetNumComponents(fv, &Nc);CHKERRQ(ierr); 3316c1a3d01SMatthew G. Knepley ierr = PetscFVGetDefaultTabulation(fv, &prob->basis[f], &prob->basisDer[f], NULL);CHKERRQ(ierr); 332abac5ca0SMatthew G. Knepley } else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", f); 3339de99aefSMatthew G. Knepley if (q) {ierr = PetscQuadratureGetData(q, NULL, &Nq, NULL, NULL);CHKERRQ(ierr);} 3342764a2aaSMatthew G. Knepley NqMax = PetscMax(NqMax, Nq); 3352764a2aaSMatthew G. Knepley NcMax = PetscMax(NcMax, Nc); 3362764a2aaSMatthew G. Knepley prob->totDim += Nb*Nc; 3372764a2aaSMatthew G. Knepley prob->totComp += Nc; 3382764a2aaSMatthew G. Knepley if (feBd) { 3392764a2aaSMatthew G. Knepley ierr = PetscFEGetDimension(feBd, &Nb);CHKERRQ(ierr); 3402764a2aaSMatthew G. Knepley ierr = PetscFEGetNumComponents(feBd, &Nc);CHKERRQ(ierr); 3412764a2aaSMatthew G. Knepley ierr = PetscFEGetDefaultTabulation(feBd, &prob->basisBd[f], &prob->basisDerBd[f], NULL);CHKERRQ(ierr); 3422764a2aaSMatthew G. Knepley prob->totDimBd += Nb*Nc; 3432764a2aaSMatthew G. Knepley } 3442764a2aaSMatthew G. Knepley } 3452764a2aaSMatthew G. Knepley work = PetscMax(prob->totComp*dim, PetscSqr(NcMax*dim)); 3462764a2aaSMatthew G. Knepley /* Allocate works space */ 3472764a2aaSMatthew 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); 3482764a2aaSMatthew 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); 3492764a2aaSMatthew G. Knepley if (prob->ops->setup) {ierr = (*prob->ops->setup)(prob);CHKERRQ(ierr);} 3502764a2aaSMatthew G. Knepley prob->setup = PETSC_TRUE; 3512764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 3522764a2aaSMatthew G. Knepley } 3532764a2aaSMatthew G. Knepley 3542764a2aaSMatthew G. Knepley #undef __FUNCT__ 3552764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroyStructs_Static" 3562764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSDestroyStructs_Static(PetscDS prob) 3572764a2aaSMatthew G. Knepley { 3582764a2aaSMatthew G. Knepley PetscErrorCode ierr; 3592764a2aaSMatthew G. Knepley 3602764a2aaSMatthew G. Knepley PetscFunctionBegin; 3612764a2aaSMatthew G. Knepley ierr = PetscFree4(prob->basis,prob->basisDer,prob->basisBd,prob->basisDerBd);CHKERRQ(ierr); 3622764a2aaSMatthew G. Knepley ierr = PetscFree5(prob->u,prob->u_t,prob->u_x,prob->x,prob->refSpaceDer);CHKERRQ(ierr); 3632764a2aaSMatthew G. Knepley ierr = PetscFree6(prob->f0,prob->f1,prob->g0,prob->g1,prob->g2,prob->g3);CHKERRQ(ierr); 3642764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 3652764a2aaSMatthew G. Knepley } 3662764a2aaSMatthew G. Knepley 3672764a2aaSMatthew G. Knepley #undef __FUNCT__ 3682764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSEnlarge_Static" 3692764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSEnlarge_Static(PetscDS prob, PetscInt NfNew) 3702764a2aaSMatthew G. Knepley { 3712764a2aaSMatthew G. Knepley PetscObject *tmpd, *tmpdbd; 372*249df284SMatthew G. Knepley PetscBool *tmpi; 3732764a2aaSMatthew G. Knepley PointFunc *tmpobj, *tmpf, *tmpg; 3742764a2aaSMatthew G. Knepley BdPointFunc *tmpfbd, *tmpgbd; 3750c2f2876SMatthew G. Knepley RiemannFunc *tmpr; 3760c2f2876SMatthew G. Knepley void **tmpctx; 3772764a2aaSMatthew G. Knepley PetscInt Nf = prob->Nf, f; 3782764a2aaSMatthew G. Knepley PetscErrorCode ierr; 3792764a2aaSMatthew G. Knepley 3802764a2aaSMatthew G. Knepley PetscFunctionBegin; 3812764a2aaSMatthew G. Knepley if (Nf >= NfNew) PetscFunctionReturn(0); 3822764a2aaSMatthew G. Knepley prob->setup = PETSC_FALSE; 3832764a2aaSMatthew G. Knepley ierr = PetscDSDestroyStructs_Static(prob);CHKERRQ(ierr); 3842764a2aaSMatthew G. Knepley ierr = PetscMalloc1(NfNew, &tmpd);CHKERRQ(ierr); 385*249df284SMatthew G. Knepley ierr = PetscMalloc1(NfNew, &tmpi);CHKERRQ(ierr); 386*249df284SMatthew G. Knepley for (f = 0; f < Nf; ++f) {tmpd[f] = prob->disc[f]; tmpi[f] = prob->implicit[f];} 387*249df284SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) {ierr = PetscContainerCreate(PetscObjectComm((PetscObject) prob), (PetscContainer *) &tmpd[f]);CHKERRQ(ierr); tmpi[f] = PETSC_TRUE;} 3882764a2aaSMatthew G. Knepley ierr = PetscFree(prob->disc);CHKERRQ(ierr); 389*249df284SMatthew G. Knepley ierr = PetscFree(prob->implicit);CHKERRQ(ierr); 3902764a2aaSMatthew G. Knepley prob->Nf = NfNew; 3912764a2aaSMatthew G. Knepley prob->disc = tmpd; 392*249df284SMatthew G. Knepley prob->implicit = tmpi; 3930c2f2876SMatthew G. Knepley ierr = PetscCalloc5(NfNew, &tmpobj, NfNew*2, &tmpf, NfNew*NfNew*4, &tmpg, NfNew, &tmpr, NfNew, &tmpctx);CHKERRQ(ierr); 3942764a2aaSMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpobj[f] = prob->obj[f]; 3952764a2aaSMatthew G. Knepley for (f = 0; f < Nf*2; ++f) tmpf[f] = prob->f[f]; 3962764a2aaSMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpg[f] = prob->g[f]; 3970c2f2876SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpr[f] = prob->r[f]; 3980c2f2876SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpctx[f] = prob->ctx[f]; 3992764a2aaSMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpobj[f] = NULL; 4002764a2aaSMatthew G. Knepley for (f = Nf*2; f < NfNew*2; ++f) tmpf[f] = NULL; 4012764a2aaSMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpg[f] = NULL; 4020c2f2876SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpr[f] = NULL; 4030c2f2876SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpctx[f] = NULL; 4040c2f2876SMatthew G. Knepley ierr = PetscFree5(prob->obj, prob->f, prob->g, prob->r, prob->ctx);CHKERRQ(ierr); 4052764a2aaSMatthew G. Knepley prob->obj = tmpobj; 4062764a2aaSMatthew G. Knepley prob->f = tmpf; 4072764a2aaSMatthew G. Knepley prob->g = tmpg; 4080c2f2876SMatthew G. Knepley prob->r = tmpr; 4090c2f2876SMatthew G. Knepley prob->ctx = tmpctx; 4102764a2aaSMatthew G. Knepley ierr = PetscMalloc1(NfNew, &tmpdbd);CHKERRQ(ierr); 4112764a2aaSMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpdbd[f] = prob->discBd[f]; 4122764a2aaSMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpdbd[f] = NULL; 4132764a2aaSMatthew G. Knepley ierr = PetscFree(prob->discBd);CHKERRQ(ierr); 4142764a2aaSMatthew G. Knepley prob->discBd = tmpdbd; 4152764a2aaSMatthew G. Knepley ierr = PetscCalloc2(NfNew*2, &tmpfbd, NfNew*NfNew*4, &tmpgbd);CHKERRQ(ierr); 4162764a2aaSMatthew G. Knepley for (f = 0; f < Nf*2; ++f) tmpfbd[f] = prob->fBd[f]; 4172764a2aaSMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpgbd[f] = prob->gBd[f]; 4182764a2aaSMatthew G. Knepley for (f = Nf*2; f < NfNew*2; ++f) tmpfbd[f] = NULL; 4192764a2aaSMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgbd[f] = NULL; 4202764a2aaSMatthew G. Knepley ierr = PetscFree2(prob->fBd, prob->gBd);CHKERRQ(ierr); 4212764a2aaSMatthew G. Knepley prob->fBd = tmpfbd; 4222764a2aaSMatthew G. Knepley prob->gBd = tmpgbd; 4232764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4242764a2aaSMatthew G. Knepley } 4252764a2aaSMatthew G. Knepley 4262764a2aaSMatthew G. Knepley #undef __FUNCT__ 4272764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroy" 4282764a2aaSMatthew G. Knepley /*@ 4292764a2aaSMatthew G. Knepley PetscDSDestroy - Destroys a PetscDS object 4302764a2aaSMatthew G. Knepley 4312764a2aaSMatthew G. Knepley Collective on PetscDS 4322764a2aaSMatthew G. Knepley 4332764a2aaSMatthew G. Knepley Input Parameter: 4342764a2aaSMatthew G. Knepley . prob - the PetscDS object to destroy 4352764a2aaSMatthew G. Knepley 4362764a2aaSMatthew G. Knepley Level: developer 4372764a2aaSMatthew G. Knepley 4382764a2aaSMatthew G. Knepley .seealso PetscDSView() 4392764a2aaSMatthew G. Knepley @*/ 4402764a2aaSMatthew G. Knepley PetscErrorCode PetscDSDestroy(PetscDS *prob) 4412764a2aaSMatthew G. Knepley { 4422764a2aaSMatthew G. Knepley PetscInt f; 4432764a2aaSMatthew G. Knepley PetscErrorCode ierr; 4442764a2aaSMatthew G. Knepley 4452764a2aaSMatthew G. Knepley PetscFunctionBegin; 4462764a2aaSMatthew G. Knepley if (!*prob) PetscFunctionReturn(0); 4472764a2aaSMatthew G. Knepley PetscValidHeaderSpecific((*prob), PETSCDS_CLASSID, 1); 4482764a2aaSMatthew G. Knepley 4492764a2aaSMatthew G. Knepley if (--((PetscObject)(*prob))->refct > 0) {*prob = 0; PetscFunctionReturn(0);} 4502764a2aaSMatthew G. Knepley ((PetscObject) (*prob))->refct = 0; 4512764a2aaSMatthew G. Knepley ierr = PetscDSDestroyStructs_Static(*prob);CHKERRQ(ierr); 4522764a2aaSMatthew G. Knepley for (f = 0; f < (*prob)->Nf; ++f) { 4532764a2aaSMatthew G. Knepley ierr = PetscObjectDereference((*prob)->disc[f]);CHKERRQ(ierr); 4542764a2aaSMatthew G. Knepley ierr = PetscObjectDereference((*prob)->discBd[f]);CHKERRQ(ierr); 4552764a2aaSMatthew G. Knepley } 456*249df284SMatthew G. Knepley ierr = PetscFree((*prob)->implicit);CHKERRQ(ierr); 4572764a2aaSMatthew G. Knepley ierr = PetscFree((*prob)->disc);CHKERRQ(ierr); 4582764a2aaSMatthew G. Knepley ierr = PetscFree((*prob)->discBd);CHKERRQ(ierr); 4590c2f2876SMatthew G. Knepley ierr = PetscFree5((*prob)->obj,(*prob)->f,(*prob)->g,(*prob)->r,(*prob)->ctx);CHKERRQ(ierr); 4602764a2aaSMatthew G. Knepley ierr = PetscFree2((*prob)->fBd,(*prob)->gBd);CHKERRQ(ierr); 4612764a2aaSMatthew G. Knepley if ((*prob)->ops->destroy) {ierr = (*(*prob)->ops->destroy)(*prob);CHKERRQ(ierr);} 4622764a2aaSMatthew G. Knepley ierr = PetscHeaderDestroy(prob);CHKERRQ(ierr); 4632764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4642764a2aaSMatthew G. Knepley } 4652764a2aaSMatthew G. Knepley 4662764a2aaSMatthew G. Knepley #undef __FUNCT__ 4672764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSCreate" 4682764a2aaSMatthew G. Knepley /*@ 4692764a2aaSMatthew G. Knepley PetscDSCreate - Creates an empty PetscDS object. The type can then be set with PetscDSSetType(). 4702764a2aaSMatthew G. Knepley 4712764a2aaSMatthew G. Knepley Collective on MPI_Comm 4722764a2aaSMatthew G. Knepley 4732764a2aaSMatthew G. Knepley Input Parameter: 4742764a2aaSMatthew G. Knepley . comm - The communicator for the PetscDS object 4752764a2aaSMatthew G. Knepley 4762764a2aaSMatthew G. Knepley Output Parameter: 4772764a2aaSMatthew G. Knepley . prob - The PetscDS object 4782764a2aaSMatthew G. Knepley 4792764a2aaSMatthew G. Knepley Level: beginner 4802764a2aaSMatthew G. Knepley 4812764a2aaSMatthew G. Knepley .seealso: PetscDSSetType(), PETSCDSBASIC 4822764a2aaSMatthew G. Knepley @*/ 4832764a2aaSMatthew G. Knepley PetscErrorCode PetscDSCreate(MPI_Comm comm, PetscDS *prob) 4842764a2aaSMatthew G. Knepley { 4852764a2aaSMatthew G. Knepley PetscDS p; 4862764a2aaSMatthew G. Knepley PetscErrorCode ierr; 4872764a2aaSMatthew G. Knepley 4882764a2aaSMatthew G. Knepley PetscFunctionBegin; 4892764a2aaSMatthew G. Knepley PetscValidPointer(prob, 2); 4902764a2aaSMatthew G. Knepley *prob = NULL; 4912764a2aaSMatthew G. Knepley ierr = PetscDSInitializePackage();CHKERRQ(ierr); 4922764a2aaSMatthew G. Knepley 4932764a2aaSMatthew G. Knepley ierr = PetscHeaderCreate(p, _p_PetscDS, struct _PetscDSOps, PETSCDS_CLASSID, "PetscDS", "Discrete System", "PetscDS", comm, PetscDSDestroy, PetscDSView);CHKERRQ(ierr); 4942764a2aaSMatthew G. Knepley ierr = PetscMemzero(p->ops, sizeof(struct _PetscDSOps));CHKERRQ(ierr); 4952764a2aaSMatthew G. Knepley 4962764a2aaSMatthew G. Knepley p->Nf = 0; 4972764a2aaSMatthew G. Knepley p->setup = PETSC_FALSE; 4982764a2aaSMatthew G. Knepley 4992764a2aaSMatthew G. Knepley *prob = p; 5002764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5012764a2aaSMatthew G. Knepley } 5022764a2aaSMatthew G. Knepley 5032764a2aaSMatthew G. Knepley #undef __FUNCT__ 5042764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetNumFields" 505bc4ae4beSMatthew G. Knepley /*@ 506bc4ae4beSMatthew G. Knepley PetscDSGetNumFields - Returns the number of fields in the DS 507bc4ae4beSMatthew G. Knepley 508bc4ae4beSMatthew G. Knepley Not collective 509bc4ae4beSMatthew G. Knepley 510bc4ae4beSMatthew G. Knepley Input Parameter: 511bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 512bc4ae4beSMatthew G. Knepley 513bc4ae4beSMatthew G. Knepley Output Parameter: 514bc4ae4beSMatthew G. Knepley . Nf - The number of fields 515bc4ae4beSMatthew G. Knepley 516bc4ae4beSMatthew G. Knepley Level: beginner 517bc4ae4beSMatthew G. Knepley 518bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetSpatialDimension(), PetscDSCreate() 519bc4ae4beSMatthew G. Knepley @*/ 5202764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetNumFields(PetscDS prob, PetscInt *Nf) 5212764a2aaSMatthew G. Knepley { 5222764a2aaSMatthew G. Knepley PetscFunctionBegin; 5232764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 5242764a2aaSMatthew G. Knepley PetscValidPointer(Nf, 2); 5252764a2aaSMatthew G. Knepley *Nf = prob->Nf; 5262764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5272764a2aaSMatthew G. Knepley } 5282764a2aaSMatthew G. Knepley 5292764a2aaSMatthew G. Knepley #undef __FUNCT__ 5302764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetSpatialDimension" 531bc4ae4beSMatthew G. Knepley /*@ 532bc4ae4beSMatthew G. Knepley PetscDSGetSpatialDimension - Returns the spatial dimension of the DS 533bc4ae4beSMatthew G. Knepley 534bc4ae4beSMatthew G. Knepley Not collective 535bc4ae4beSMatthew G. Knepley 536bc4ae4beSMatthew G. Knepley Input Parameter: 537bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 538bc4ae4beSMatthew G. Knepley 539bc4ae4beSMatthew G. Knepley Output Parameter: 540bc4ae4beSMatthew G. Knepley . dim - The spatial dimension 541bc4ae4beSMatthew G. Knepley 542bc4ae4beSMatthew G. Knepley Level: beginner 543bc4ae4beSMatthew G. Knepley 544bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 545bc4ae4beSMatthew G. Knepley @*/ 5462764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetSpatialDimension(PetscDS prob, PetscInt *dim) 5472764a2aaSMatthew G. Knepley { 5482764a2aaSMatthew G. Knepley PetscErrorCode ierr; 5492764a2aaSMatthew G. Knepley 5502764a2aaSMatthew G. Knepley PetscFunctionBegin; 5512764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 5522764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 5532764a2aaSMatthew G. Knepley *dim = 0; 5549de99aefSMatthew G. Knepley if (prob->Nf) { 5559de99aefSMatthew G. Knepley PetscObject obj; 5569de99aefSMatthew G. Knepley PetscClassId id; 5579de99aefSMatthew G. Knepley 5589de99aefSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, 0, &obj);CHKERRQ(ierr); 5599de99aefSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 5609de99aefSMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEGetSpatialDimension((PetscFE) obj, dim);CHKERRQ(ierr);} 5619de99aefSMatthew G. Knepley else if (id == PETSCFV_CLASSID) {ierr = PetscFVGetSpatialDimension((PetscFV) obj, dim);CHKERRQ(ierr);} 5629de99aefSMatthew G. Knepley else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", 0); 5639de99aefSMatthew G. Knepley } 5642764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5652764a2aaSMatthew G. Knepley } 5662764a2aaSMatthew G. Knepley 5672764a2aaSMatthew G. Knepley #undef __FUNCT__ 5682764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalDimension" 569bc4ae4beSMatthew G. Knepley /*@ 570bc4ae4beSMatthew G. Knepley PetscDSGetTotalDimension - Returns the total size of the approximation space for this system 571bc4ae4beSMatthew G. Knepley 572bc4ae4beSMatthew G. Knepley Not collective 573bc4ae4beSMatthew G. Knepley 574bc4ae4beSMatthew G. Knepley Input Parameter: 575bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 576bc4ae4beSMatthew G. Knepley 577bc4ae4beSMatthew G. Knepley Output Parameter: 578bc4ae4beSMatthew G. Knepley . dim - The total problem dimension 579bc4ae4beSMatthew G. Knepley 580bc4ae4beSMatthew G. Knepley Level: beginner 581bc4ae4beSMatthew G. Knepley 582bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 583bc4ae4beSMatthew G. Knepley @*/ 5842764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalDimension(PetscDS prob, PetscInt *dim) 5852764a2aaSMatthew G. Knepley { 5862764a2aaSMatthew G. Knepley PetscErrorCode ierr; 5872764a2aaSMatthew G. Knepley 5882764a2aaSMatthew G. Knepley PetscFunctionBegin; 5892764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 5902764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 5912764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 5922764a2aaSMatthew G. Knepley *dim = prob->totDim; 5932764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5942764a2aaSMatthew G. Knepley } 5952764a2aaSMatthew G. Knepley 5962764a2aaSMatthew G. Knepley #undef __FUNCT__ 5972764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalBdDimension" 598bc4ae4beSMatthew G. Knepley /*@ 599c3ac4435SMatthew G. Knepley PetscDSGetTotalBdDimension - Returns the total size of the boundary approximation space for this system 600bc4ae4beSMatthew G. Knepley 601bc4ae4beSMatthew G. Knepley Not collective 602bc4ae4beSMatthew G. Knepley 603bc4ae4beSMatthew G. Knepley Input Parameter: 604bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 605bc4ae4beSMatthew G. Knepley 606bc4ae4beSMatthew G. Knepley Output Parameter: 607bc4ae4beSMatthew G. Knepley . dim - The total boundary problem dimension 608bc4ae4beSMatthew G. Knepley 609bc4ae4beSMatthew G. Knepley Level: beginner 610bc4ae4beSMatthew G. Knepley 611bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 612bc4ae4beSMatthew G. Knepley @*/ 6132764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalBdDimension(PetscDS prob, PetscInt *dim) 6142764a2aaSMatthew G. Knepley { 6152764a2aaSMatthew G. Knepley PetscErrorCode ierr; 6162764a2aaSMatthew G. Knepley 6172764a2aaSMatthew G. Knepley PetscFunctionBegin; 6182764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6192764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 6202764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 6212764a2aaSMatthew G. Knepley *dim = prob->totDimBd; 6222764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6232764a2aaSMatthew G. Knepley } 6242764a2aaSMatthew G. Knepley 6252764a2aaSMatthew G. Knepley #undef __FUNCT__ 6262764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalComponents" 627bc4ae4beSMatthew G. Knepley /*@ 628bc4ae4beSMatthew G. Knepley PetscDSGetTotalComponents - Returns the total number of components in this system 629bc4ae4beSMatthew G. Knepley 630bc4ae4beSMatthew G. Knepley Not collective 631bc4ae4beSMatthew G. Knepley 632bc4ae4beSMatthew G. Knepley Input Parameter: 633bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 634bc4ae4beSMatthew G. Knepley 635bc4ae4beSMatthew G. Knepley Output Parameter: 636bc4ae4beSMatthew G. Knepley . dim - The total number of components 637bc4ae4beSMatthew G. Knepley 638bc4ae4beSMatthew G. Knepley Level: beginner 639bc4ae4beSMatthew G. Knepley 640bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 641bc4ae4beSMatthew G. Knepley @*/ 6422764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalComponents(PetscDS prob, PetscInt *Nc) 6432764a2aaSMatthew G. Knepley { 6442764a2aaSMatthew G. Knepley PetscErrorCode ierr; 6452764a2aaSMatthew G. Knepley 6462764a2aaSMatthew G. Knepley PetscFunctionBegin; 6472764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6482764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 6492764a2aaSMatthew G. Knepley PetscValidPointer(Nc, 2); 6502764a2aaSMatthew G. Knepley *Nc = prob->totComp; 6512764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6522764a2aaSMatthew G. Knepley } 6532764a2aaSMatthew G. Knepley 6542764a2aaSMatthew G. Knepley #undef __FUNCT__ 6552764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetDiscretization" 656bc4ae4beSMatthew G. Knepley /*@ 657bc4ae4beSMatthew G. Knepley PetscDSGetDiscretization - Returns the discretization object for the given field 658bc4ae4beSMatthew G. Knepley 659bc4ae4beSMatthew G. Knepley Not collective 660bc4ae4beSMatthew G. Knepley 661bc4ae4beSMatthew G. Knepley Input Parameters: 662bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 663bc4ae4beSMatthew G. Knepley - f - The field number 664bc4ae4beSMatthew G. Knepley 665bc4ae4beSMatthew G. Knepley Output Parameter: 666bc4ae4beSMatthew G. Knepley . disc - The discretization object 667bc4ae4beSMatthew G. Knepley 668bc4ae4beSMatthew G. Knepley Level: beginner 669bc4ae4beSMatthew G. Knepley 670bc4ae4beSMatthew G. Knepley .seealso: PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 671bc4ae4beSMatthew G. Knepley @*/ 6722764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetDiscretization(PetscDS prob, PetscInt f, PetscObject *disc) 6732764a2aaSMatthew G. Knepley { 6742764a2aaSMatthew G. Knepley PetscFunctionBegin; 6752764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6762764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 6772764a2aaSMatthew 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); 6782764a2aaSMatthew G. Knepley *disc = prob->disc[f]; 6792764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6802764a2aaSMatthew G. Knepley } 6812764a2aaSMatthew G. Knepley 6822764a2aaSMatthew G. Knepley #undef __FUNCT__ 6832764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdDiscretization" 684bc4ae4beSMatthew G. Knepley /*@ 685bc4ae4beSMatthew G. Knepley PetscDSGetBdDiscretization - Returns the boundary discretization object for the given field 686bc4ae4beSMatthew G. Knepley 687bc4ae4beSMatthew G. Knepley Not collective 688bc4ae4beSMatthew G. Knepley 689bc4ae4beSMatthew G. Knepley Input Parameters: 690bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 691bc4ae4beSMatthew G. Knepley - f - The field number 692bc4ae4beSMatthew G. Knepley 693bc4ae4beSMatthew G. Knepley Output Parameter: 694bc4ae4beSMatthew G. Knepley . disc - The boundary discretization object 695bc4ae4beSMatthew G. Knepley 696bc4ae4beSMatthew G. Knepley Level: beginner 697bc4ae4beSMatthew G. Knepley 698bc4ae4beSMatthew G. Knepley .seealso: PetscDSSetBdDiscretization(), PetscDSAddBdDiscretization(), PetscDSGetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 699bc4ae4beSMatthew G. Knepley @*/ 7002764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdDiscretization(PetscDS prob, PetscInt f, PetscObject *disc) 7012764a2aaSMatthew G. Knepley { 7022764a2aaSMatthew G. Knepley PetscFunctionBegin; 7032764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7042764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 7052764a2aaSMatthew 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); 7062764a2aaSMatthew G. Knepley *disc = prob->discBd[f]; 7072764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7082764a2aaSMatthew G. Knepley } 7092764a2aaSMatthew G. Knepley 7102764a2aaSMatthew G. Knepley #undef __FUNCT__ 7112764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetDiscretization" 712bc4ae4beSMatthew G. Knepley /*@ 713bc4ae4beSMatthew G. Knepley PetscDSSetDiscretization - Sets the discretization object for the given field 714bc4ae4beSMatthew G. Knepley 715bc4ae4beSMatthew G. Knepley Not collective 716bc4ae4beSMatthew G. Knepley 717bc4ae4beSMatthew G. Knepley Input Parameters: 718bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 719bc4ae4beSMatthew G. Knepley . f - The field number 720bc4ae4beSMatthew G. Knepley - disc - The discretization object 721bc4ae4beSMatthew G. Knepley 722bc4ae4beSMatthew G. Knepley Level: beginner 723bc4ae4beSMatthew G. Knepley 724bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 725bc4ae4beSMatthew G. Knepley @*/ 7262764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetDiscretization(PetscDS prob, PetscInt f, PetscObject disc) 7272764a2aaSMatthew G. Knepley { 7282764a2aaSMatthew G. Knepley PetscErrorCode ierr; 7292764a2aaSMatthew G. Knepley 7302764a2aaSMatthew G. Knepley PetscFunctionBegin; 7312764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7322764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 7332764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 7342764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 7352764a2aaSMatthew G. Knepley if (prob->disc[f]) {ierr = PetscObjectDereference(prob->disc[f]);CHKERRQ(ierr);} 7362764a2aaSMatthew G. Knepley prob->disc[f] = disc; 7372764a2aaSMatthew G. Knepley ierr = PetscObjectReference(disc);CHKERRQ(ierr); 738*249df284SMatthew G. Knepley { 739*249df284SMatthew G. Knepley PetscClassId id; 740*249df284SMatthew G. Knepley 741*249df284SMatthew G. Knepley ierr = PetscObjectGetClassId(disc, &id);CHKERRQ(ierr); 742*249df284SMatthew G. Knepley if (id == PETSCFV_CLASSID) prob->implicit[f] = PETSC_FALSE; 743*249df284SMatthew G. Knepley } 7442764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7452764a2aaSMatthew G. Knepley } 7462764a2aaSMatthew G. Knepley 7472764a2aaSMatthew G. Knepley #undef __FUNCT__ 7482764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdDiscretization" 749bc4ae4beSMatthew G. Knepley /*@ 750bc4ae4beSMatthew G. Knepley PetscDSSetBdDiscretization - Sets the boundary discretization object for the given field 751bc4ae4beSMatthew G. Knepley 752bc4ae4beSMatthew G. Knepley Not collective 753bc4ae4beSMatthew G. Knepley 754bc4ae4beSMatthew G. Knepley Input Parameters: 755bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 756bc4ae4beSMatthew G. Knepley . f - The field number 757bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object 758bc4ae4beSMatthew G. Knepley 759bc4ae4beSMatthew G. Knepley Level: beginner 760bc4ae4beSMatthew G. Knepley 761bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetBdDiscretization(), PetscDSAddBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 762bc4ae4beSMatthew G. Knepley @*/ 7632764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdDiscretization(PetscDS prob, PetscInt f, PetscObject disc) 7642764a2aaSMatthew G. Knepley { 7652764a2aaSMatthew G. Knepley PetscErrorCode ierr; 7662764a2aaSMatthew G. Knepley 7672764a2aaSMatthew G. Knepley PetscFunctionBegin; 7682764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7692764a2aaSMatthew G. Knepley if (disc) PetscValidPointer(disc, 3); 7702764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 7712764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 7722764a2aaSMatthew G. Knepley if (prob->discBd[f]) {ierr = PetscObjectDereference(prob->discBd[f]);CHKERRQ(ierr);} 7732764a2aaSMatthew G. Knepley prob->discBd[f] = disc; 7742764a2aaSMatthew G. Knepley ierr = PetscObjectReference(disc);CHKERRQ(ierr); 7752764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7762764a2aaSMatthew G. Knepley } 7772764a2aaSMatthew G. Knepley 7782764a2aaSMatthew G. Knepley #undef __FUNCT__ 7792764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSAddDiscretization" 780bc4ae4beSMatthew G. Knepley /*@ 781bc4ae4beSMatthew G. Knepley PetscDSAddDiscretization - Adds a discretization object 782bc4ae4beSMatthew G. Knepley 783bc4ae4beSMatthew G. Knepley Not collective 784bc4ae4beSMatthew G. Knepley 785bc4ae4beSMatthew G. Knepley Input Parameters: 786bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 787bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object 788bc4ae4beSMatthew G. Knepley 789bc4ae4beSMatthew G. Knepley Level: beginner 790bc4ae4beSMatthew G. Knepley 791bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSSetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 792bc4ae4beSMatthew G. Knepley @*/ 7932764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddDiscretization(PetscDS prob, PetscObject disc) 7942764a2aaSMatthew G. Knepley { 7952764a2aaSMatthew G. Knepley PetscErrorCode ierr; 7962764a2aaSMatthew G. Knepley 7972764a2aaSMatthew G. Knepley PetscFunctionBegin; 7982764a2aaSMatthew G. Knepley ierr = PetscDSSetDiscretization(prob, prob->Nf, disc);CHKERRQ(ierr); 7992764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8002764a2aaSMatthew G. Knepley } 8012764a2aaSMatthew G. Knepley 8022764a2aaSMatthew G. Knepley #undef __FUNCT__ 8032764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSAddBdDiscretization" 804bc4ae4beSMatthew G. Knepley /*@ 805bc4ae4beSMatthew G. Knepley PetscDSAddBdDiscretization - Adds a boundary discretization object 806bc4ae4beSMatthew G. Knepley 807bc4ae4beSMatthew G. Knepley Not collective 808bc4ae4beSMatthew G. Knepley 809bc4ae4beSMatthew G. Knepley Input Parameters: 810bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 811bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object 812bc4ae4beSMatthew G. Knepley 813bc4ae4beSMatthew G. Knepley Level: beginner 814bc4ae4beSMatthew G. Knepley 815bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetBdDiscretization(), PetscDSSetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 816bc4ae4beSMatthew G. Knepley @*/ 8172764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddBdDiscretization(PetscDS prob, PetscObject disc) 8182764a2aaSMatthew G. Knepley { 8192764a2aaSMatthew G. Knepley PetscErrorCode ierr; 8202764a2aaSMatthew G. Knepley 8212764a2aaSMatthew G. Knepley PetscFunctionBegin; 8222764a2aaSMatthew G. Knepley ierr = PetscDSSetBdDiscretization(prob, prob->Nf, disc);CHKERRQ(ierr); 8232764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8242764a2aaSMatthew G. Knepley } 8252764a2aaSMatthew G. Knepley 8262764a2aaSMatthew G. Knepley #undef __FUNCT__ 827*249df284SMatthew G. Knepley #define __FUNCT__ "PetscDSGetImplicit" 828*249df284SMatthew G. Knepley /*@ 829*249df284SMatthew G. Knepley PetscDSGetImplicit - Returns the flag for implicit solve for this field. This is just a guide for IMEX 830*249df284SMatthew G. Knepley 831*249df284SMatthew G. Knepley Not collective 832*249df284SMatthew G. Knepley 833*249df284SMatthew G. Knepley Input Parameters: 834*249df284SMatthew G. Knepley + prob - The PetscDS object 835*249df284SMatthew G. Knepley - f - The field number 836*249df284SMatthew G. Knepley 837*249df284SMatthew G. Knepley Output Parameter: 838*249df284SMatthew G. Knepley . implicit - The flag indicating what kind of solve to use for this field 839*249df284SMatthew G. Knepley 840*249df284SMatthew G. Knepley Level: developer 841*249df284SMatthew G. Knepley 842*249df284SMatthew G. Knepley .seealso: PetscDSSetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 843*249df284SMatthew G. Knepley @*/ 844*249df284SMatthew G. Knepley PetscErrorCode PetscDSGetImplicit(PetscDS prob, PetscInt f, PetscBool *implicit) 845*249df284SMatthew G. Knepley { 846*249df284SMatthew G. Knepley PetscFunctionBegin; 847*249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 848*249df284SMatthew G. Knepley PetscValidPointer(implicit, 3); 849*249df284SMatthew 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); 850*249df284SMatthew G. Knepley *implicit = prob->implicit[f]; 851*249df284SMatthew G. Knepley PetscFunctionReturn(0); 852*249df284SMatthew G. Knepley } 853*249df284SMatthew G. Knepley 854*249df284SMatthew G. Knepley #undef __FUNCT__ 855*249df284SMatthew G. Knepley #define __FUNCT__ "PetscDSSetImplicit" 856*249df284SMatthew G. Knepley /*@ 857*249df284SMatthew G. Knepley PetscDSSetImplicit - Set the flag for implicit solve for this field. This is just a guide for IMEX 858*249df284SMatthew G. Knepley 859*249df284SMatthew G. Knepley Not collective 860*249df284SMatthew G. Knepley 861*249df284SMatthew G. Knepley Input Parameters: 862*249df284SMatthew G. Knepley + prob - The PetscDS object 863*249df284SMatthew G. Knepley . f - The field number 864*249df284SMatthew G. Knepley - implicit - The flag indicating what kind of solve to use for this field 865*249df284SMatthew G. Knepley 866*249df284SMatthew G. Knepley Level: developer 867*249df284SMatthew G. Knepley 868*249df284SMatthew G. Knepley .seealso: PetscDSGetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 869*249df284SMatthew G. Knepley @*/ 870*249df284SMatthew G. Knepley PetscErrorCode PetscDSSetImplicit(PetscDS prob, PetscInt f, PetscBool implicit) 871*249df284SMatthew G. Knepley { 872*249df284SMatthew G. Knepley PetscFunctionBegin; 873*249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 874*249df284SMatthew 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); 875*249df284SMatthew G. Knepley prob->implicit[f] = implicit; 876*249df284SMatthew G. Knepley PetscFunctionReturn(0); 877*249df284SMatthew G. Knepley } 878*249df284SMatthew G. Knepley 879*249df284SMatthew G. Knepley #undef __FUNCT__ 8802764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetObjective" 8812764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetObjective(PetscDS prob, PetscInt f, 8822764a2aaSMatthew G. Knepley void (**obj)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], PetscScalar obj[])) 8832764a2aaSMatthew G. Knepley { 8842764a2aaSMatthew G. Knepley PetscFunctionBegin; 8852764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 8862764a2aaSMatthew G. Knepley PetscValidPointer(obj, 2); 8872764a2aaSMatthew 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); 8882764a2aaSMatthew G. Knepley *obj = prob->obj[f]; 8892764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8902764a2aaSMatthew G. Knepley } 8912764a2aaSMatthew G. Knepley 8922764a2aaSMatthew G. Knepley #undef __FUNCT__ 8932764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetObjective" 8942764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetObjective(PetscDS prob, PetscInt f, 8952764a2aaSMatthew G. Knepley void (*obj)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], PetscScalar obj[])) 8962764a2aaSMatthew G. Knepley { 8972764a2aaSMatthew G. Knepley PetscErrorCode ierr; 8982764a2aaSMatthew G. Knepley 8992764a2aaSMatthew G. Knepley PetscFunctionBegin; 9002764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 9012764a2aaSMatthew G. Knepley PetscValidFunction(obj, 2); 9022764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 9032764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 9042764a2aaSMatthew G. Knepley prob->obj[f] = obj; 9052764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9062764a2aaSMatthew G. Knepley } 9072764a2aaSMatthew G. Knepley 9082764a2aaSMatthew G. Knepley #undef __FUNCT__ 9092764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetResidual" 9102764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetResidual(PetscDS prob, PetscInt f, 9112764a2aaSMatthew G. Knepley void (**f0)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], PetscScalar f0[]), 9122764a2aaSMatthew G. Knepley void (**f1)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], PetscScalar f1[])) 9132764a2aaSMatthew G. Knepley { 9142764a2aaSMatthew G. Knepley PetscFunctionBegin; 9152764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 9162764a2aaSMatthew 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); 9172764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 3); *f0 = prob->f[f*2+0];} 9182764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 4); *f1 = prob->f[f*2+1];} 9192764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9202764a2aaSMatthew G. Knepley } 9212764a2aaSMatthew G. Knepley 9222764a2aaSMatthew G. Knepley #undef __FUNCT__ 9232764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetResidual" 9242764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetResidual(PetscDS prob, PetscInt f, 9252764a2aaSMatthew G. Knepley void (*f0)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], PetscScalar f0[]), 9262764a2aaSMatthew G. Knepley void (*f1)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], PetscScalar f1[])) 9272764a2aaSMatthew G. Knepley { 9282764a2aaSMatthew G. Knepley PetscErrorCode ierr; 9292764a2aaSMatthew G. Knepley 9302764a2aaSMatthew G. Knepley PetscFunctionBegin; 9312764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 9322764a2aaSMatthew G. Knepley PetscValidFunction(f0, 3); 9332764a2aaSMatthew G. Knepley PetscValidFunction(f1, 4); 9342764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 9352764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 9362764a2aaSMatthew G. Knepley prob->f[f*2+0] = f0; 9372764a2aaSMatthew G. Knepley prob->f[f*2+1] = f1; 9382764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9392764a2aaSMatthew G. Knepley } 9402764a2aaSMatthew G. Knepley 9412764a2aaSMatthew G. Knepley #undef __FUNCT__ 9422764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetJacobian" 9432764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetJacobian(PetscDS prob, PetscInt f, PetscInt g, 9442764a2aaSMatthew G. Knepley void (**g0)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], PetscScalar g0[]), 9452764a2aaSMatthew G. Knepley void (**g1)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], PetscScalar g1[]), 9462764a2aaSMatthew G. Knepley void (**g2)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], PetscScalar g2[]), 9472764a2aaSMatthew G. Knepley void (**g3)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], PetscScalar g3[])) 9482764a2aaSMatthew G. Knepley { 9492764a2aaSMatthew G. Knepley PetscFunctionBegin; 9502764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 9512764a2aaSMatthew 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); 9522764a2aaSMatthew 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); 9532764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g[(f*prob->Nf + g)*4+0];} 9542764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g[(f*prob->Nf + g)*4+1];} 9552764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g[(f*prob->Nf + g)*4+2];} 9562764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g[(f*prob->Nf + g)*4+3];} 9572764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9582764a2aaSMatthew G. Knepley } 9592764a2aaSMatthew G. Knepley 9602764a2aaSMatthew G. Knepley #undef __FUNCT__ 9612764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetJacobian" 9622764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetJacobian(PetscDS prob, PetscInt f, PetscInt g, 9632764a2aaSMatthew G. Knepley void (*g0)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], PetscScalar g0[]), 9642764a2aaSMatthew G. Knepley void (*g1)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], PetscScalar g1[]), 9652764a2aaSMatthew G. Knepley void (*g2)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], PetscScalar g2[]), 9662764a2aaSMatthew G. Knepley void (*g3)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], PetscScalar g3[])) 9672764a2aaSMatthew G. Knepley { 9682764a2aaSMatthew G. Knepley PetscErrorCode ierr; 9692764a2aaSMatthew G. Knepley 9702764a2aaSMatthew G. Knepley PetscFunctionBegin; 9712764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 9722764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 9732764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 9742764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 9752764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 9762764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 9772764a2aaSMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 9782764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 9792764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+0] = g0; 9802764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+1] = g1; 9812764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+2] = g2; 9822764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+3] = g3; 9832764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9842764a2aaSMatthew G. Knepley } 9852764a2aaSMatthew G. Knepley 9862764a2aaSMatthew G. Knepley #undef __FUNCT__ 9870c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSGetRiemannSolver" 9880c2f2876SMatthew G. Knepley /*@C 9890c2f2876SMatthew G. Knepley PetscDSGetRiemannSolver - Returns the Riemann solver for the given field 9900c2f2876SMatthew G. Knepley 9910c2f2876SMatthew G. Knepley Not collective 9920c2f2876SMatthew G. Knepley 9930c2f2876SMatthew G. Knepley Input Arguments: 9940c2f2876SMatthew G. Knepley + prob - The PetscDS object 9950c2f2876SMatthew G. Knepley - f - The field number 9960c2f2876SMatthew G. Knepley 9970c2f2876SMatthew G. Knepley Output Argument: 9980c2f2876SMatthew G. Knepley . r - Riemann solver 9990c2f2876SMatthew G. Knepley 10000c2f2876SMatthew G. Knepley Calling sequence for r: 10010c2f2876SMatthew G. Knepley 10020c2f2876SMatthew G. Knepley $ r(const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 10030c2f2876SMatthew G. Knepley 10040c2f2876SMatthew G. Knepley + x - The coordinates at a point on the interface 10050c2f2876SMatthew G. Knepley . n - The normal vector to the interface 10060c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 10070c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 10080c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 10090c2f2876SMatthew G. Knepley - ctx - optional user context 10100c2f2876SMatthew G. Knepley 10110c2f2876SMatthew G. Knepley Level: intermediate 10120c2f2876SMatthew G. Knepley 10130c2f2876SMatthew G. Knepley .seealso: PetscDSSetRiemannSolver() 10140c2f2876SMatthew G. Knepley @*/ 10150c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetRiemannSolver(PetscDS prob, PetscInt f, 10160c2f2876SMatthew G. Knepley void (**r)(const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx)) 10170c2f2876SMatthew G. Knepley { 10180c2f2876SMatthew G. Knepley PetscFunctionBegin; 10190c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 10200c2f2876SMatthew 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); 10210c2f2876SMatthew G. Knepley PetscValidPointer(r, 3); 10220c2f2876SMatthew G. Knepley *r = prob->r[f]; 10230c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 10240c2f2876SMatthew G. Knepley } 10250c2f2876SMatthew G. Knepley 10260c2f2876SMatthew G. Knepley #undef __FUNCT__ 10270c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSSetRiemannSolver" 10280c2f2876SMatthew G. Knepley /*@C 10290c2f2876SMatthew G. Knepley PetscDSSetRiemannSolver - Sets the Riemann solver for the given field 10300c2f2876SMatthew G. Knepley 10310c2f2876SMatthew G. Knepley Not collective 10320c2f2876SMatthew G. Knepley 10330c2f2876SMatthew G. Knepley Input Arguments: 10340c2f2876SMatthew G. Knepley + prob - The PetscDS object 10350c2f2876SMatthew G. Knepley . f - The field number 10360c2f2876SMatthew G. Knepley - r - Riemann solver 10370c2f2876SMatthew G. Knepley 10380c2f2876SMatthew G. Knepley Calling sequence for r: 10390c2f2876SMatthew G. Knepley 10400c2f2876SMatthew G. Knepley $ r(const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 10410c2f2876SMatthew G. Knepley 10420c2f2876SMatthew G. Knepley + x - The coordinates at a point on the interface 10430c2f2876SMatthew G. Knepley . n - The normal vector to the interface 10440c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 10450c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 10460c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 10470c2f2876SMatthew G. Knepley - ctx - optional user context 10480c2f2876SMatthew G. Knepley 10490c2f2876SMatthew G. Knepley Level: intermediate 10500c2f2876SMatthew G. Knepley 10510c2f2876SMatthew G. Knepley .seealso: PetscDSGetRiemannSolver() 10520c2f2876SMatthew G. Knepley @*/ 10530c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetRiemannSolver(PetscDS prob, PetscInt f, 10540c2f2876SMatthew G. Knepley void (*r)(const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx)) 10550c2f2876SMatthew G. Knepley { 10560c2f2876SMatthew G. Knepley PetscErrorCode ierr; 10570c2f2876SMatthew G. Knepley 10580c2f2876SMatthew G. Knepley PetscFunctionBegin; 10590c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 10600c2f2876SMatthew G. Knepley PetscValidFunction(r, 3); 10610c2f2876SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 10620c2f2876SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 10630c2f2876SMatthew G. Knepley prob->r[f] = r; 10640c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 10650c2f2876SMatthew G. Knepley } 10660c2f2876SMatthew G. Knepley 10670c2f2876SMatthew G. Knepley #undef __FUNCT__ 10680c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSGetContext" 10690c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetContext(PetscDS prob, PetscInt f, void **ctx) 10700c2f2876SMatthew G. Knepley { 10710c2f2876SMatthew G. Knepley PetscFunctionBegin; 10720c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 10730c2f2876SMatthew 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); 10740c2f2876SMatthew G. Knepley PetscValidPointer(ctx, 3); 10750c2f2876SMatthew G. Knepley *ctx = prob->ctx[f]; 10760c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 10770c2f2876SMatthew G. Knepley } 10780c2f2876SMatthew G. Knepley 10790c2f2876SMatthew G. Knepley #undef __FUNCT__ 10800c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSSetContext" 10810c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetContext(PetscDS prob, PetscInt f, void *ctx) 10820c2f2876SMatthew G. Knepley { 10830c2f2876SMatthew G. Knepley PetscErrorCode ierr; 10840c2f2876SMatthew G. Knepley 10850c2f2876SMatthew G. Knepley PetscFunctionBegin; 10860c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 10870c2f2876SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 10880c2f2876SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 10890c2f2876SMatthew G. Knepley prob->ctx[f] = ctx; 10900c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 10910c2f2876SMatthew G. Knepley } 10920c2f2876SMatthew G. Knepley 10930c2f2876SMatthew G. Knepley #undef __FUNCT__ 10942764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdResidual" 10952764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdResidual(PetscDS prob, PetscInt f, 10962764a2aaSMatthew G. Knepley void (**f0)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], const PetscReal n[], PetscScalar f0[]), 10972764a2aaSMatthew G. Knepley void (**f1)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], const PetscReal n[], PetscScalar f1[])) 10982764a2aaSMatthew G. Knepley { 10992764a2aaSMatthew G. Knepley PetscFunctionBegin; 11002764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 11012764a2aaSMatthew 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); 11022764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 3); *f0 = prob->fBd[f*2+0];} 11032764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 4); *f1 = prob->fBd[f*2+1];} 11042764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 11052764a2aaSMatthew G. Knepley } 11062764a2aaSMatthew G. Knepley 11072764a2aaSMatthew G. Knepley #undef __FUNCT__ 11082764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdResidual" 11092764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdResidual(PetscDS prob, PetscInt f, 11102764a2aaSMatthew G. Knepley void (*f0)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], const PetscReal n[], PetscScalar f0[]), 11112764a2aaSMatthew G. Knepley void (*f1)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], const PetscReal n[], PetscScalar f1[])) 11122764a2aaSMatthew G. Knepley { 11132764a2aaSMatthew G. Knepley PetscErrorCode ierr; 11142764a2aaSMatthew G. Knepley 11152764a2aaSMatthew G. Knepley PetscFunctionBegin; 11162764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 11172764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 11182764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 11192764a2aaSMatthew G. Knepley if (f0) {PetscValidFunction(f0, 3); prob->fBd[f*2+0] = f0;} 11202764a2aaSMatthew G. Knepley if (f1) {PetscValidFunction(f1, 4); prob->fBd[f*2+1] = f1;} 11212764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 11222764a2aaSMatthew G. Knepley } 11232764a2aaSMatthew G. Knepley 11242764a2aaSMatthew G. Knepley #undef __FUNCT__ 11252764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdJacobian" 11262764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdJacobian(PetscDS prob, PetscInt f, PetscInt g, 11272764a2aaSMatthew G. Knepley void (**g0)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], const PetscReal n[], PetscScalar g0[]), 11282764a2aaSMatthew G. Knepley void (**g1)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], const PetscReal n[], PetscScalar g1[]), 11292764a2aaSMatthew G. Knepley void (**g2)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], const PetscReal n[], PetscScalar g2[]), 11302764a2aaSMatthew G. Knepley void (**g3)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], const PetscReal n[], PetscScalar g3[])) 11312764a2aaSMatthew G. Knepley { 11322764a2aaSMatthew G. Knepley PetscFunctionBegin; 11332764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 11342764a2aaSMatthew 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); 11352764a2aaSMatthew 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); 11362764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gBd[(f*prob->Nf + g)*4+0];} 11372764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gBd[(f*prob->Nf + g)*4+1];} 11382764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gBd[(f*prob->Nf + g)*4+2];} 11392764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gBd[(f*prob->Nf + g)*4+3];} 11402764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 11412764a2aaSMatthew G. Knepley } 11422764a2aaSMatthew G. Knepley 11432764a2aaSMatthew G. Knepley #undef __FUNCT__ 11442764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdJacobian" 11452764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdJacobian(PetscDS prob, PetscInt f, PetscInt g, 11462764a2aaSMatthew G. Knepley void (*g0)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], const PetscReal n[], PetscScalar g0[]), 11472764a2aaSMatthew G. Knepley void (*g1)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], const PetscReal n[], PetscScalar g1[]), 11482764a2aaSMatthew G. Knepley void (*g2)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], const PetscReal n[], PetscScalar g2[]), 11492764a2aaSMatthew G. Knepley void (*g3)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], const PetscReal n[], PetscScalar g3[])) 11502764a2aaSMatthew G. Knepley { 11512764a2aaSMatthew G. Knepley PetscErrorCode ierr; 11522764a2aaSMatthew G. Knepley 11532764a2aaSMatthew G. Knepley PetscFunctionBegin; 11542764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 11552764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 11562764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 11572764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 11582764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 11592764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 11602764a2aaSMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 11612764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 11622764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+0] = g0; 11632764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+1] = g1; 11642764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+2] = g2; 11652764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+3] = g3; 11662764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 11672764a2aaSMatthew G. Knepley } 11682764a2aaSMatthew G. Knepley 11692764a2aaSMatthew G. Knepley #undef __FUNCT__ 11702764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetFieldOffset" 1171bc4ae4beSMatthew G. Knepley /*@ 1172bc4ae4beSMatthew G. Knepley PetscDSGetFieldOffset - Returns the offset of the given field in the full space basis 1173bc4ae4beSMatthew G. Knepley 1174bc4ae4beSMatthew G. Knepley Not collective 1175bc4ae4beSMatthew G. Knepley 1176bc4ae4beSMatthew G. Knepley Input Parameters: 1177bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 1178bc4ae4beSMatthew G. Knepley - f - The field number 1179bc4ae4beSMatthew G. Knepley 1180bc4ae4beSMatthew G. Knepley Output Parameter: 1181bc4ae4beSMatthew G. Knepley . off - The offset 1182bc4ae4beSMatthew G. Knepley 1183bc4ae4beSMatthew G. Knepley Level: beginner 1184bc4ae4beSMatthew G. Knepley 1185bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 1186bc4ae4beSMatthew G. Knepley @*/ 11872764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetFieldOffset(PetscDS prob, PetscInt f, PetscInt *off) 11882764a2aaSMatthew G. Knepley { 11892764a2aaSMatthew G. Knepley PetscInt g; 11902764a2aaSMatthew G. Knepley PetscErrorCode ierr; 11912764a2aaSMatthew G. Knepley 11922764a2aaSMatthew G. Knepley PetscFunctionBegin; 11932764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 11942764a2aaSMatthew G. Knepley PetscValidPointer(off, 3); 11952764a2aaSMatthew 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); 11962764a2aaSMatthew G. Knepley *off = 0; 11972764a2aaSMatthew G. Knepley for (g = 0; g < f; ++g) { 11982764a2aaSMatthew G. Knepley PetscFE fe = (PetscFE) prob->disc[g]; 11992764a2aaSMatthew G. Knepley PetscInt Nb, Nc; 12002764a2aaSMatthew G. Knepley 12012764a2aaSMatthew G. Knepley ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr); 12022764a2aaSMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 12032764a2aaSMatthew G. Knepley *off += Nb*Nc; 12042764a2aaSMatthew G. Knepley } 12052764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 12062764a2aaSMatthew G. Knepley } 12072764a2aaSMatthew G. Knepley 12082764a2aaSMatthew G. Knepley #undef __FUNCT__ 12092764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdFieldOffset" 1210bc4ae4beSMatthew G. Knepley /*@ 1211c3ac4435SMatthew G. Knepley PetscDSGetBdFieldOffset - Returns the offset of the given field in the full space boundary basis 1212bc4ae4beSMatthew G. Knepley 1213bc4ae4beSMatthew G. Knepley Not collective 1214bc4ae4beSMatthew G. Knepley 1215bc4ae4beSMatthew G. Knepley Input Parameters: 1216bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 1217bc4ae4beSMatthew G. Knepley - f - The field number 1218bc4ae4beSMatthew G. Knepley 1219bc4ae4beSMatthew G. Knepley Output Parameter: 1220bc4ae4beSMatthew G. Knepley . off - The boundary offset 1221bc4ae4beSMatthew G. Knepley 1222bc4ae4beSMatthew G. Knepley Level: beginner 1223bc4ae4beSMatthew G. Knepley 1224bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 1225bc4ae4beSMatthew G. Knepley @*/ 12262764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdFieldOffset(PetscDS prob, PetscInt f, PetscInt *off) 12272764a2aaSMatthew G. Knepley { 12282764a2aaSMatthew G. Knepley PetscInt g; 12292764a2aaSMatthew G. Knepley PetscErrorCode ierr; 12302764a2aaSMatthew G. Knepley 12312764a2aaSMatthew G. Knepley PetscFunctionBegin; 12322764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 12332764a2aaSMatthew G. Knepley PetscValidPointer(off, 3); 12342764a2aaSMatthew 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); 12352764a2aaSMatthew G. Knepley *off = 0; 12362764a2aaSMatthew G. Knepley for (g = 0; g < f; ++g) { 12372764a2aaSMatthew G. Knepley PetscFE fe = (PetscFE) prob->discBd[g]; 12382764a2aaSMatthew G. Knepley PetscInt Nb, Nc; 12392764a2aaSMatthew G. Knepley 12402764a2aaSMatthew G. Knepley ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr); 12412764a2aaSMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 12422764a2aaSMatthew G. Knepley *off += Nb*Nc; 12436ce16762SMatthew G. Knepley } 12446ce16762SMatthew G. Knepley PetscFunctionReturn(0); 12456ce16762SMatthew G. Knepley } 12466ce16762SMatthew G. Knepley 12476ce16762SMatthew G. Knepley #undef __FUNCT__ 12486ce16762SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentOffset" 12496ce16762SMatthew G. Knepley /*@ 12506ce16762SMatthew G. Knepley PetscDSGetComponentOffset - Returns the offset of the given field on an evaluation point 12516ce16762SMatthew G. Knepley 12526ce16762SMatthew G. Knepley Not collective 12536ce16762SMatthew G. Knepley 12546ce16762SMatthew G. Knepley Input Parameters: 12556ce16762SMatthew G. Knepley + prob - The PetscDS object 12566ce16762SMatthew G. Knepley - f - The field number 12576ce16762SMatthew G. Knepley 12586ce16762SMatthew G. Knepley Output Parameter: 12596ce16762SMatthew G. Knepley . off - The offset 12606ce16762SMatthew G. Knepley 12616ce16762SMatthew G. Knepley Level: beginner 12626ce16762SMatthew G. Knepley 12636ce16762SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 12646ce16762SMatthew G. Knepley @*/ 12656ce16762SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffset(PetscDS prob, PetscInt f, PetscInt *off) 12666ce16762SMatthew G. Knepley { 12676ce16762SMatthew G. Knepley PetscInt g; 12686ce16762SMatthew G. Knepley PetscErrorCode ierr; 12696ce16762SMatthew G. Knepley 12706ce16762SMatthew G. Knepley PetscFunctionBegin; 12716ce16762SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 12726ce16762SMatthew G. Knepley PetscValidPointer(off, 3); 12736ce16762SMatthew 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); 12746ce16762SMatthew G. Knepley *off = 0; 12756ce16762SMatthew G. Knepley for (g = 0; g < f; ++g) { 12766ce16762SMatthew G. Knepley PetscFE fe = (PetscFE) prob->disc[g]; 12776ce16762SMatthew G. Knepley PetscInt Nc; 12786ce16762SMatthew G. Knepley 12796ce16762SMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 12806ce16762SMatthew G. Knepley *off += Nc; 12812764a2aaSMatthew G. Knepley } 12822764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 12832764a2aaSMatthew G. Knepley } 12842764a2aaSMatthew G. Knepley 12852764a2aaSMatthew G. Knepley #undef __FUNCT__ 12862764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTabulation" 128768c9edb9SMatthew G. Knepley /*@C 128868c9edb9SMatthew G. Knepley PetscDSGetTabulation - Return the basis tabulation at quadrature points for the volume discretization 128968c9edb9SMatthew G. Knepley 129068c9edb9SMatthew G. Knepley Not collective 129168c9edb9SMatthew G. Knepley 129268c9edb9SMatthew G. Knepley Input Parameter: 129368c9edb9SMatthew G. Knepley . prob - The PetscDS object 129468c9edb9SMatthew G. Knepley 129568c9edb9SMatthew G. Knepley Output Parameters: 129668c9edb9SMatthew G. Knepley + basis - The basis function tabulation at quadrature points 129768c9edb9SMatthew G. Knepley - basisDer - The basis function derivative tabulation at quadrature points 129868c9edb9SMatthew G. Knepley 129968c9edb9SMatthew G. Knepley Level: intermediate 130068c9edb9SMatthew G. Knepley 130168c9edb9SMatthew G. Knepley .seealso: PetscDSGetBdTabulation(), PetscDSCreate() 130268c9edb9SMatthew G. Knepley @*/ 13032764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTabulation(PetscDS prob, PetscReal ***basis, PetscReal ***basisDer) 13042764a2aaSMatthew G. Knepley { 13052764a2aaSMatthew G. Knepley PetscErrorCode ierr; 13062764a2aaSMatthew G. Knepley 13072764a2aaSMatthew G. Knepley PetscFunctionBegin; 13082764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 13092764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 13102764a2aaSMatthew G. Knepley if (basis) {PetscValidPointer(basis, 2); *basis = prob->basis;} 13112764a2aaSMatthew G. Knepley if (basisDer) {PetscValidPointer(basisDer, 3); *basisDer = prob->basisDer;} 13122764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 13132764a2aaSMatthew G. Knepley } 13142764a2aaSMatthew G. Knepley 13152764a2aaSMatthew G. Knepley #undef __FUNCT__ 13162764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdTabulation" 131768c9edb9SMatthew G. Knepley /*@C 131868c9edb9SMatthew G. Knepley PetscDSGetBdTabulation - Return the basis tabulation at quadrature points for the boundary discretization 131968c9edb9SMatthew G. Knepley 132068c9edb9SMatthew G. Knepley Not collective 132168c9edb9SMatthew G. Knepley 132268c9edb9SMatthew G. Knepley Input Parameter: 132368c9edb9SMatthew G. Knepley . prob - The PetscDS object 132468c9edb9SMatthew G. Knepley 132568c9edb9SMatthew G. Knepley Output Parameters: 132668c9edb9SMatthew G. Knepley + basis - The basis function tabulation at quadrature points 132768c9edb9SMatthew G. Knepley - basisDer - The basis function derivative tabulation at quadrature points 132868c9edb9SMatthew G. Knepley 132968c9edb9SMatthew G. Knepley Level: intermediate 133068c9edb9SMatthew G. Knepley 133168c9edb9SMatthew G. Knepley .seealso: PetscDSGetTabulation(), PetscDSCreate() 133268c9edb9SMatthew G. Knepley @*/ 13332764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdTabulation(PetscDS prob, PetscReal ***basis, PetscReal ***basisDer) 13342764a2aaSMatthew G. Knepley { 13352764a2aaSMatthew G. Knepley PetscErrorCode ierr; 13362764a2aaSMatthew G. Knepley 13372764a2aaSMatthew G. Knepley PetscFunctionBegin; 13382764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 13392764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 13402764a2aaSMatthew G. Knepley if (basis) {PetscValidPointer(basis, 2); *basis = prob->basisBd;} 13412764a2aaSMatthew G. Knepley if (basisDer) {PetscValidPointer(basisDer, 3); *basisDer = prob->basisDerBd;} 13422764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 13432764a2aaSMatthew G. Knepley } 13442764a2aaSMatthew G. Knepley 13452764a2aaSMatthew G. Knepley #undef __FUNCT__ 13462764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetEvaluationArrays" 13472764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetEvaluationArrays(PetscDS prob, PetscScalar **u, PetscScalar **u_t, PetscScalar **u_x) 13482764a2aaSMatthew G. Knepley { 13492764a2aaSMatthew G. Knepley PetscErrorCode ierr; 13502764a2aaSMatthew G. Knepley 13512764a2aaSMatthew G. Knepley PetscFunctionBegin; 13522764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 13532764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 13542764a2aaSMatthew G. Knepley if (u) {PetscValidPointer(u, 2); *u = prob->u;} 13552764a2aaSMatthew G. Knepley if (u_t) {PetscValidPointer(u_t, 3); *u_t = prob->u_t;} 13562764a2aaSMatthew G. Knepley if (u_x) {PetscValidPointer(u_x, 4); *u_x = prob->u_x;} 13572764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 13582764a2aaSMatthew G. Knepley } 13592764a2aaSMatthew G. Knepley 13602764a2aaSMatthew G. Knepley #undef __FUNCT__ 13612764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetWeakFormArrays" 13622764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetWeakFormArrays(PetscDS prob, PetscScalar **f0, PetscScalar **f1, PetscScalar **g0, PetscScalar **g1, PetscScalar **g2, PetscScalar **g3) 13632764a2aaSMatthew G. Knepley { 13642764a2aaSMatthew G. Knepley PetscErrorCode ierr; 13652764a2aaSMatthew G. Knepley 13662764a2aaSMatthew G. Knepley PetscFunctionBegin; 13672764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 13682764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 13692764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 2); *f0 = prob->f0;} 13702764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 3); *f1 = prob->f1;} 13712764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g0;} 13722764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g1;} 13732764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g2;} 13742764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g3;} 13752764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 13762764a2aaSMatthew G. Knepley } 13772764a2aaSMatthew G. Knepley 13782764a2aaSMatthew G. Knepley #undef __FUNCT__ 13792764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetRefCoordArrays" 13802764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetRefCoordArrays(PetscDS prob, PetscReal **x, PetscScalar **refSpaceDer) 13812764a2aaSMatthew G. Knepley { 13822764a2aaSMatthew G. Knepley PetscErrorCode ierr; 13832764a2aaSMatthew G. Knepley 13842764a2aaSMatthew G. Knepley PetscFunctionBegin; 13852764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 13862764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 13872764a2aaSMatthew G. Knepley if (x) {PetscValidPointer(x, 2); *x = prob->x;} 13882764a2aaSMatthew G. Knepley if (refSpaceDer) {PetscValidPointer(refSpaceDer, 3); *refSpaceDer = prob->refSpaceDer;} 13892764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 13902764a2aaSMatthew G. Knepley } 13912764a2aaSMatthew G. Knepley 13922764a2aaSMatthew G. Knepley #undef __FUNCT__ 13932764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroy_Basic" 1394bc4ae4beSMatthew G. Knepley static PetscErrorCode PetscDSDestroy_Basic(PetscDS prob) 13952764a2aaSMatthew G. Knepley { 13962764a2aaSMatthew G. Knepley PetscFunctionBegin; 13972764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 13982764a2aaSMatthew G. Knepley } 13992764a2aaSMatthew G. Knepley 14002764a2aaSMatthew G. Knepley #undef __FUNCT__ 14012764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSInitialize_Basic" 1402bc4ae4beSMatthew G. Knepley static PetscErrorCode PetscDSInitialize_Basic(PetscDS prob) 14032764a2aaSMatthew G. Knepley { 14042764a2aaSMatthew G. Knepley PetscFunctionBegin; 14052764a2aaSMatthew G. Knepley prob->ops->setfromoptions = NULL; 14062764a2aaSMatthew G. Knepley prob->ops->setup = NULL; 14072764a2aaSMatthew G. Knepley prob->ops->view = NULL; 14082764a2aaSMatthew G. Knepley prob->ops->destroy = PetscDSDestroy_Basic; 14092764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 14102764a2aaSMatthew G. Knepley } 14112764a2aaSMatthew G. Knepley 14122764a2aaSMatthew G. Knepley /*MC 14132764a2aaSMatthew G. Knepley PETSCDSBASIC = "basic" - A discrete system with pointwise residual and boundary residual functions 14142764a2aaSMatthew G. Knepley 14152764a2aaSMatthew G. Knepley Level: intermediate 14162764a2aaSMatthew G. Knepley 14172764a2aaSMatthew G. Knepley .seealso: PetscDSType, PetscDSCreate(), PetscDSSetType() 14182764a2aaSMatthew G. Knepley M*/ 14192764a2aaSMatthew G. Knepley 14202764a2aaSMatthew G. Knepley #undef __FUNCT__ 14212764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSCreate_Basic" 14222764a2aaSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscDSCreate_Basic(PetscDS prob) 14232764a2aaSMatthew G. Knepley { 14242764a2aaSMatthew G. Knepley PetscDS_Basic *b; 14252764a2aaSMatthew G. Knepley PetscErrorCode ierr; 14262764a2aaSMatthew G. Knepley 14272764a2aaSMatthew G. Knepley PetscFunctionBegin; 14282764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCSPACE_CLASSID, 1); 14292764a2aaSMatthew G. Knepley ierr = PetscNewLog(prob, &b);CHKERRQ(ierr); 14302764a2aaSMatthew G. Knepley prob->data = b; 14312764a2aaSMatthew G. Knepley 14322764a2aaSMatthew G. Knepley ierr = PetscDSInitialize_Basic(prob);CHKERRQ(ierr); 14332764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 14342764a2aaSMatthew G. Knepley } 1435