1af0996ceSBarry Smith #include <petsc/private/petscdsimpl.h> /*I "petscds.h" I*/ 22764a2aaSMatthew G. Knepley 32764a2aaSMatthew G. Knepley PetscClassId PETSCDS_CLASSID = 0; 42764a2aaSMatthew G. Knepley 52764a2aaSMatthew G. Knepley PetscFunctionList PetscDSList = NULL; 62764a2aaSMatthew G. Knepley PetscBool PetscDSRegisterAllCalled = PETSC_FALSE; 72764a2aaSMatthew G. Knepley 82764a2aaSMatthew G. Knepley #undef __FUNCT__ 92764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSRegister" 102764a2aaSMatthew G. Knepley /*@C 112764a2aaSMatthew G. Knepley PetscDSRegister - Adds a new PetscDS implementation 122764a2aaSMatthew G. Knepley 132764a2aaSMatthew G. Knepley Not Collective 142764a2aaSMatthew G. Knepley 152764a2aaSMatthew G. Knepley Input Parameters: 162764a2aaSMatthew G. Knepley + name - The name of a new user-defined creation routine 172764a2aaSMatthew G. Knepley - create_func - The creation routine itself 182764a2aaSMatthew G. Knepley 192764a2aaSMatthew G. Knepley Notes: 202764a2aaSMatthew G. Knepley PetscDSRegister() may be called multiple times to add several user-defined PetscDSs 212764a2aaSMatthew G. Knepley 222764a2aaSMatthew G. Knepley Sample usage: 232764a2aaSMatthew G. Knepley .vb 242764a2aaSMatthew G. Knepley PetscDSRegister("my_ds", MyPetscDSCreate); 252764a2aaSMatthew G. Knepley .ve 262764a2aaSMatthew G. Knepley 272764a2aaSMatthew G. Knepley Then, your PetscDS type can be chosen with the procedural interface via 282764a2aaSMatthew G. Knepley .vb 292764a2aaSMatthew G. Knepley PetscDSCreate(MPI_Comm, PetscDS *); 302764a2aaSMatthew G. Knepley PetscDSSetType(PetscDS, "my_ds"); 312764a2aaSMatthew G. Knepley .ve 322764a2aaSMatthew G. Knepley or at runtime via the option 332764a2aaSMatthew G. Knepley .vb 342764a2aaSMatthew G. Knepley -petscds_type my_ds 352764a2aaSMatthew G. Knepley .ve 362764a2aaSMatthew G. Knepley 372764a2aaSMatthew G. Knepley Level: advanced 382764a2aaSMatthew G. Knepley 392764a2aaSMatthew G. Knepley .keywords: PetscDS, register 402764a2aaSMatthew G. Knepley .seealso: PetscDSRegisterAll(), PetscDSRegisterDestroy() 412764a2aaSMatthew G. Knepley 422764a2aaSMatthew G. Knepley @*/ 432764a2aaSMatthew G. Knepley PetscErrorCode PetscDSRegister(const char sname[], PetscErrorCode (*function)(PetscDS)) 442764a2aaSMatthew G. Knepley { 452764a2aaSMatthew G. Knepley PetscErrorCode ierr; 462764a2aaSMatthew G. Knepley 472764a2aaSMatthew G. Knepley PetscFunctionBegin; 482764a2aaSMatthew G. Knepley ierr = PetscFunctionListAdd(&PetscDSList, sname, function);CHKERRQ(ierr); 492764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 502764a2aaSMatthew G. Knepley } 512764a2aaSMatthew G. Knepley 522764a2aaSMatthew G. Knepley #undef __FUNCT__ 532764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetType" 542764a2aaSMatthew G. Knepley /*@C 552764a2aaSMatthew G. Knepley PetscDSSetType - Builds a particular PetscDS 562764a2aaSMatthew G. Knepley 572764a2aaSMatthew G. Knepley Collective on PetscDS 582764a2aaSMatthew G. Knepley 592764a2aaSMatthew G. Knepley Input Parameters: 602764a2aaSMatthew G. Knepley + prob - The PetscDS object 612764a2aaSMatthew G. Knepley - name - The kind of system 622764a2aaSMatthew G. Knepley 632764a2aaSMatthew G. Knepley Options Database Key: 642764a2aaSMatthew G. Knepley . -petscds_type <type> - Sets the PetscDS type; use -help for a list of available types 652764a2aaSMatthew G. Knepley 662764a2aaSMatthew G. Knepley Level: intermediate 672764a2aaSMatthew G. Knepley 682764a2aaSMatthew G. Knepley .keywords: PetscDS, set, type 692764a2aaSMatthew G. Knepley .seealso: PetscDSGetType(), PetscDSCreate() 702764a2aaSMatthew G. Knepley @*/ 712764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetType(PetscDS prob, PetscDSType name) 722764a2aaSMatthew G. Knepley { 732764a2aaSMatthew G. Knepley PetscErrorCode (*r)(PetscDS); 742764a2aaSMatthew G. Knepley PetscBool match; 752764a2aaSMatthew G. Knepley PetscErrorCode ierr; 762764a2aaSMatthew G. Knepley 772764a2aaSMatthew G. Knepley PetscFunctionBegin; 782764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 792764a2aaSMatthew G. Knepley ierr = PetscObjectTypeCompare((PetscObject) prob, name, &match);CHKERRQ(ierr); 802764a2aaSMatthew G. Knepley if (match) PetscFunctionReturn(0); 812764a2aaSMatthew G. Knepley 820f51fdf8SToby Isaac ierr = PetscDSRegisterAll();CHKERRQ(ierr); 832764a2aaSMatthew G. Knepley ierr = PetscFunctionListFind(PetscDSList, name, &r);CHKERRQ(ierr); 842764a2aaSMatthew G. Knepley if (!r) SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_UNKNOWN_TYPE, "Unknown PetscDS type: %s", name); 852764a2aaSMatthew G. Knepley 862764a2aaSMatthew G. Knepley if (prob->ops->destroy) { 872764a2aaSMatthew G. Knepley ierr = (*prob->ops->destroy)(prob);CHKERRQ(ierr); 882764a2aaSMatthew G. Knepley prob->ops->destroy = NULL; 892764a2aaSMatthew G. Knepley } 902764a2aaSMatthew G. Knepley ierr = (*r)(prob);CHKERRQ(ierr); 912764a2aaSMatthew G. Knepley ierr = PetscObjectChangeTypeName((PetscObject) prob, name);CHKERRQ(ierr); 922764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 932764a2aaSMatthew G. Knepley } 942764a2aaSMatthew G. Knepley 952764a2aaSMatthew G. Knepley #undef __FUNCT__ 962764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetType" 972764a2aaSMatthew G. Knepley /*@C 982764a2aaSMatthew G. Knepley PetscDSGetType - Gets the PetscDS type name (as a string) from the object. 992764a2aaSMatthew G. Knepley 1002764a2aaSMatthew G. Knepley Not Collective 1012764a2aaSMatthew G. Knepley 1022764a2aaSMatthew G. Knepley Input Parameter: 1032764a2aaSMatthew G. Knepley . prob - The PetscDS 1042764a2aaSMatthew G. Knepley 1052764a2aaSMatthew G. Knepley Output Parameter: 1062764a2aaSMatthew G. Knepley . name - The PetscDS type name 1072764a2aaSMatthew G. Knepley 1082764a2aaSMatthew G. Knepley Level: intermediate 1092764a2aaSMatthew G. Knepley 1102764a2aaSMatthew G. Knepley .keywords: PetscDS, get, type, name 1112764a2aaSMatthew G. Knepley .seealso: PetscDSSetType(), PetscDSCreate() 1122764a2aaSMatthew G. Knepley @*/ 1132764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetType(PetscDS prob, PetscDSType *name) 1142764a2aaSMatthew G. Knepley { 1152764a2aaSMatthew G. Knepley PetscErrorCode ierr; 1162764a2aaSMatthew G. Knepley 1172764a2aaSMatthew G. Knepley PetscFunctionBegin; 1182764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 119c959eef4SJed Brown PetscValidPointer(name, 2); 1200f51fdf8SToby Isaac ierr = PetscDSRegisterAll();CHKERRQ(ierr); 1212764a2aaSMatthew G. Knepley *name = ((PetscObject) prob)->type_name; 1222764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 1232764a2aaSMatthew G. Knepley } 1242764a2aaSMatthew G. Knepley 1252764a2aaSMatthew G. Knepley #undef __FUNCT__ 1267d8a60eaSMatthew G. Knepley #define __FUNCT__ "PetscDSView_Ascii" 1277d8a60eaSMatthew G. Knepley static PetscErrorCode PetscDSView_Ascii(PetscDS prob, PetscViewer viewer) 1287d8a60eaSMatthew G. Knepley { 1297d8a60eaSMatthew G. Knepley PetscViewerFormat format; 1307d8a60eaSMatthew G. Knepley PetscInt f; 1317d8a60eaSMatthew G. Knepley PetscErrorCode ierr; 1327d8a60eaSMatthew G. Knepley 1337d8a60eaSMatthew G. Knepley PetscFunctionBegin; 1347d8a60eaSMatthew G. Knepley ierr = PetscViewerGetFormat(viewer, &format);CHKERRQ(ierr); 1357d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "Discrete System with %d fields\n", prob->Nf);CHKERRQ(ierr); 1367d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); 1377d8a60eaSMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 1387d8a60eaSMatthew G. Knepley PetscObject obj; 1397d8a60eaSMatthew G. Knepley PetscClassId id; 1407d8a60eaSMatthew G. Knepley const char *name; 1417d8a60eaSMatthew G. Knepley PetscInt Nc; 1427d8a60eaSMatthew G. Knepley 1437d8a60eaSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr); 1447d8a60eaSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 1457d8a60eaSMatthew G. Knepley ierr = PetscObjectGetName(obj, &name);CHKERRQ(ierr); 1467d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "Field %s", name ? name : "<unknown>");CHKERRQ(ierr); 1477d8a60eaSMatthew G. Knepley if (id == PETSCFE_CLASSID) { 1487d8a60eaSMatthew G. Knepley ierr = PetscFEGetNumComponents((PetscFE) obj, &Nc);CHKERRQ(ierr); 1497d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, " FEM");CHKERRQ(ierr); 1507d8a60eaSMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 1517d8a60eaSMatthew G. Knepley ierr = PetscFVGetNumComponents((PetscFV) obj, &Nc);CHKERRQ(ierr); 1527d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, " FVM");CHKERRQ(ierr); 1537d8a60eaSMatthew G. Knepley } 1547d8a60eaSMatthew G. Knepley else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", f); 1557d8a60eaSMatthew G. Knepley if (Nc > 1) {ierr = PetscViewerASCIIPrintf(viewer, "%d components", Nc);CHKERRQ(ierr);} 1567d8a60eaSMatthew G. Knepley else {ierr = PetscViewerASCIIPrintf(viewer, "%d component ", Nc);CHKERRQ(ierr);} 157249df284SMatthew G. Knepley if (prob->implicit[f]) {ierr = PetscViewerASCIIPrintf(viewer, " (implicit)");CHKERRQ(ierr);} 158249df284SMatthew G. Knepley else {ierr = PetscViewerASCIIPrintf(viewer, " (explicit)");CHKERRQ(ierr);} 159a6cbbb48SMatthew G. Knepley if (prob->adjacency[f*2+0]) { 160a6cbbb48SMatthew G. Knepley if (prob->adjacency[f*2+1]) {ierr = PetscViewerASCIIPrintf(viewer, " (adj FVM++)");CHKERRQ(ierr);} 161a6cbbb48SMatthew G. Knepley else {ierr = PetscViewerASCIIPrintf(viewer, " (adj FVM)");CHKERRQ(ierr);} 162a6cbbb48SMatthew G. Knepley } else { 163a6cbbb48SMatthew G. Knepley if (prob->adjacency[f*2+1]) {ierr = PetscViewerASCIIPrintf(viewer, " (adj FEM)");CHKERRQ(ierr);} 164a6cbbb48SMatthew G. Knepley else {ierr = PetscViewerASCIIPrintf(viewer, " (adj FUNKY)");CHKERRQ(ierr);} 165a6cbbb48SMatthew G. Knepley } 1667d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "\n");CHKERRQ(ierr); 1677d8a60eaSMatthew G. Knepley if (format == PETSC_VIEWER_ASCII_INFO_DETAIL) { 1687d8a60eaSMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEView((PetscFE) obj, viewer);CHKERRQ(ierr);} 1697d8a60eaSMatthew G. Knepley else if (id == PETSCFV_CLASSID) {ierr = PetscFVView((PetscFV) obj, viewer);CHKERRQ(ierr);} 1707d8a60eaSMatthew G. Knepley } 1717d8a60eaSMatthew G. Knepley } 1727d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); 1737d8a60eaSMatthew G. Knepley PetscFunctionReturn(0); 1747d8a60eaSMatthew G. Knepley } 1757d8a60eaSMatthew G. Knepley 1767d8a60eaSMatthew G. Knepley #undef __FUNCT__ 1772764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSView" 1782764a2aaSMatthew G. Knepley /*@C 1792764a2aaSMatthew G. Knepley PetscDSView - Views a PetscDS 1802764a2aaSMatthew G. Knepley 1812764a2aaSMatthew G. Knepley Collective on PetscDS 1822764a2aaSMatthew G. Knepley 1832764a2aaSMatthew G. Knepley Input Parameter: 1842764a2aaSMatthew G. Knepley + prob - the PetscDS object to view 1852764a2aaSMatthew G. Knepley - v - the viewer 1862764a2aaSMatthew G. Knepley 1872764a2aaSMatthew G. Knepley Level: developer 1882764a2aaSMatthew G. Knepley 1892764a2aaSMatthew G. Knepley .seealso PetscDSDestroy() 1902764a2aaSMatthew G. Knepley @*/ 1912764a2aaSMatthew G. Knepley PetscErrorCode PetscDSView(PetscDS prob, PetscViewer v) 1922764a2aaSMatthew G. Knepley { 1937d8a60eaSMatthew G. Knepley PetscBool iascii; 1942764a2aaSMatthew G. Knepley PetscErrorCode ierr; 1952764a2aaSMatthew G. Knepley 1962764a2aaSMatthew G. Knepley PetscFunctionBegin; 1972764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1982764a2aaSMatthew G. Knepley if (!v) {ierr = PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject) prob), &v);CHKERRQ(ierr);} 1997d8a60eaSMatthew G. Knepley else {PetscValidHeaderSpecific(v, PETSC_VIEWER_CLASSID, 2);} 2007d8a60eaSMatthew G. Knepley ierr = PetscObjectTypeCompare((PetscObject) v, PETSCVIEWERASCII, &iascii);CHKERRQ(ierr); 2017d8a60eaSMatthew G. Knepley if (iascii) {ierr = PetscDSView_Ascii(prob, v);CHKERRQ(ierr);} 2022764a2aaSMatthew G. Knepley if (prob->ops->view) {ierr = (*prob->ops->view)(prob, v);CHKERRQ(ierr);} 2032764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 2042764a2aaSMatthew G. Knepley } 2052764a2aaSMatthew G. Knepley 2062764a2aaSMatthew G. Knepley #undef __FUNCT__ 2072764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSViewFromOptions" 2082764a2aaSMatthew G. Knepley /* 2092764a2aaSMatthew G. Knepley PetscDSViewFromOptions - Processes command line options to determine if/how a PetscDS is to be viewed. 2102764a2aaSMatthew G. Knepley 2112764a2aaSMatthew G. Knepley Collective on PetscDS 2122764a2aaSMatthew G. Knepley 2132764a2aaSMatthew G. Knepley Input Parameters: 2142764a2aaSMatthew G. Knepley + prob - the PetscDS 2152764a2aaSMatthew G. Knepley . prefix - prefix to use for viewing, or NULL to use prefix of 'rnd' 2162764a2aaSMatthew G. Knepley - optionname - option to activate viewing 2172764a2aaSMatthew G. Knepley 2182764a2aaSMatthew G. Knepley Level: intermediate 2192764a2aaSMatthew G. Knepley 2202764a2aaSMatthew G. Knepley .keywords: PetscDS, view, options, database 2212764a2aaSMatthew G. Knepley .seealso: VecViewFromOptions(), MatViewFromOptions() 2222764a2aaSMatthew G. Knepley */ 2232764a2aaSMatthew G. Knepley PetscErrorCode PetscDSViewFromOptions(PetscDS prob, const char prefix[], const char optionname[]) 2242764a2aaSMatthew G. Knepley { 2252764a2aaSMatthew G. Knepley PetscViewer viewer; 2262764a2aaSMatthew G. Knepley PetscViewerFormat format; 2272764a2aaSMatthew G. Knepley PetscBool flg; 2282764a2aaSMatthew G. Knepley PetscErrorCode ierr; 2292764a2aaSMatthew G. Knepley 2302764a2aaSMatthew G. Knepley PetscFunctionBegin; 2312764a2aaSMatthew G. Knepley if (prefix) {ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject) prob), prefix, optionname, &viewer, &format, &flg);CHKERRQ(ierr);} 2322764a2aaSMatthew G. Knepley else {ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject) prob), ((PetscObject) prob)->prefix, optionname, &viewer, &format, &flg);CHKERRQ(ierr);} 2332764a2aaSMatthew G. Knepley if (flg) { 2342764a2aaSMatthew G. Knepley ierr = PetscViewerPushFormat(viewer, format);CHKERRQ(ierr); 2352764a2aaSMatthew G. Knepley ierr = PetscDSView(prob, viewer);CHKERRQ(ierr); 2362764a2aaSMatthew G. Knepley ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); 2372764a2aaSMatthew G. Knepley ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); 2382764a2aaSMatthew G. Knepley } 2392764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 2402764a2aaSMatthew G. Knepley } 2412764a2aaSMatthew G. Knepley 2422764a2aaSMatthew G. Knepley #undef __FUNCT__ 2432764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetFromOptions" 2442764a2aaSMatthew G. Knepley /*@ 2452764a2aaSMatthew G. Knepley PetscDSSetFromOptions - sets parameters in a PetscDS from the options database 2462764a2aaSMatthew G. Knepley 2472764a2aaSMatthew G. Knepley Collective on PetscDS 2482764a2aaSMatthew G. Knepley 2492764a2aaSMatthew G. Knepley Input Parameter: 2502764a2aaSMatthew G. Knepley . prob - the PetscDS object to set options for 2512764a2aaSMatthew G. Knepley 2522764a2aaSMatthew G. Knepley Options Database: 2532764a2aaSMatthew G. Knepley 2542764a2aaSMatthew G. Knepley Level: developer 2552764a2aaSMatthew G. Knepley 2562764a2aaSMatthew G. Knepley .seealso PetscDSView() 2572764a2aaSMatthew G. Knepley @*/ 2582764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetFromOptions(PetscDS prob) 2592764a2aaSMatthew G. Knepley { 2602764a2aaSMatthew G. Knepley const char *defaultType; 2612764a2aaSMatthew G. Knepley char name[256]; 2622764a2aaSMatthew G. Knepley PetscBool flg; 2632764a2aaSMatthew G. Knepley PetscErrorCode ierr; 2642764a2aaSMatthew G. Knepley 2652764a2aaSMatthew G. Knepley PetscFunctionBegin; 2662764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2672764a2aaSMatthew G. Knepley if (!((PetscObject) prob)->type_name) { 2682764a2aaSMatthew G. Knepley defaultType = PETSCDSBASIC; 2692764a2aaSMatthew G. Knepley } else { 2702764a2aaSMatthew G. Knepley defaultType = ((PetscObject) prob)->type_name; 2712764a2aaSMatthew G. Knepley } 2720f51fdf8SToby Isaac ierr = PetscDSRegisterAll();CHKERRQ(ierr); 2732764a2aaSMatthew G. Knepley 2742764a2aaSMatthew G. Knepley ierr = PetscObjectOptionsBegin((PetscObject) prob);CHKERRQ(ierr); 2752764a2aaSMatthew G. Knepley ierr = PetscOptionsFList("-petscds_type", "Discrete System", "PetscDSSetType", PetscDSList, defaultType, name, 256, &flg);CHKERRQ(ierr); 2762764a2aaSMatthew G. Knepley if (flg) { 2772764a2aaSMatthew G. Knepley ierr = PetscDSSetType(prob, name);CHKERRQ(ierr); 2782764a2aaSMatthew G. Knepley } else if (!((PetscObject) prob)->type_name) { 2792764a2aaSMatthew G. Knepley ierr = PetscDSSetType(prob, defaultType);CHKERRQ(ierr); 2802764a2aaSMatthew G. Knepley } 2812764a2aaSMatthew G. Knepley if (prob->ops->setfromoptions) {ierr = (*prob->ops->setfromoptions)(prob);CHKERRQ(ierr);} 2822764a2aaSMatthew G. Knepley /* process any options handlers added with PetscObjectAddOptionsHandler() */ 2832764a2aaSMatthew G. Knepley ierr = PetscObjectProcessOptionsHandlers((PetscObject) prob);CHKERRQ(ierr); 2842764a2aaSMatthew G. Knepley ierr = PetscOptionsEnd();CHKERRQ(ierr); 2852764a2aaSMatthew G. Knepley ierr = PetscDSViewFromOptions(prob, NULL, "-petscds_view");CHKERRQ(ierr); 2862764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 2872764a2aaSMatthew G. Knepley } 2882764a2aaSMatthew G. Knepley 2892764a2aaSMatthew G. Knepley #undef __FUNCT__ 2902764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetUp" 2912764a2aaSMatthew G. Knepley /*@C 2922764a2aaSMatthew G. Knepley PetscDSSetUp - Construct data structures for the PetscDS 2932764a2aaSMatthew G. Knepley 2942764a2aaSMatthew G. Knepley Collective on PetscDS 2952764a2aaSMatthew G. Knepley 2962764a2aaSMatthew G. Knepley Input Parameter: 2972764a2aaSMatthew G. Knepley . prob - the PetscDS object to setup 2982764a2aaSMatthew G. Knepley 2992764a2aaSMatthew G. Knepley Level: developer 3002764a2aaSMatthew G. Knepley 3012764a2aaSMatthew G. Knepley .seealso PetscDSView(), PetscDSDestroy() 3022764a2aaSMatthew G. Knepley @*/ 3032764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetUp(PetscDS prob) 3042764a2aaSMatthew G. Knepley { 3052764a2aaSMatthew G. Knepley const PetscInt Nf = prob->Nf; 3062764a2aaSMatthew G. Knepley PetscInt dim, work, NcMax = 0, NqMax = 0, f; 3072764a2aaSMatthew G. Knepley PetscErrorCode ierr; 3082764a2aaSMatthew G. Knepley 3092764a2aaSMatthew G. Knepley PetscFunctionBegin; 3102764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 3112764a2aaSMatthew G. Knepley if (prob->setup) PetscFunctionReturn(0); 3122764a2aaSMatthew G. Knepley /* Calculate sizes */ 3132764a2aaSMatthew G. Knepley ierr = PetscDSGetSpatialDimension(prob, &dim);CHKERRQ(ierr); 3142764a2aaSMatthew G. Knepley prob->totDim = prob->totDimBd = prob->totComp = 0; 315194d53e6SMatthew G. Knepley ierr = PetscCalloc4(Nf+1,&prob->off,Nf+1,&prob->offDer,Nf+1,&prob->offBd,Nf+1,&prob->offDerBd);CHKERRQ(ierr); 3162764a2aaSMatthew G. Knepley ierr = PetscMalloc4(Nf,&prob->basis,Nf,&prob->basisDer,Nf,&prob->basisBd,Nf,&prob->basisDerBd);CHKERRQ(ierr); 3172764a2aaSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 3182764a2aaSMatthew G. Knepley PetscFE feBd = (PetscFE) prob->discBd[f]; 3199de99aefSMatthew G. Knepley PetscObject obj; 3209de99aefSMatthew G. Knepley PetscClassId id; 3212764a2aaSMatthew G. Knepley PetscQuadrature q; 3229de99aefSMatthew G. Knepley PetscInt Nq = 0, Nb, Nc; 3232764a2aaSMatthew G. Knepley 3249de99aefSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr); 3259de99aefSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 3269de99aefSMatthew G. Knepley if (id == PETSCFE_CLASSID) { 3279de99aefSMatthew G. Knepley PetscFE fe = (PetscFE) obj; 3289de99aefSMatthew G. Knepley 3292764a2aaSMatthew G. Knepley ierr = PetscFEGetQuadrature(fe, &q);CHKERRQ(ierr); 3302764a2aaSMatthew G. Knepley ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr); 3312764a2aaSMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 3322764a2aaSMatthew G. Knepley ierr = PetscFEGetDefaultTabulation(fe, &prob->basis[f], &prob->basisDer[f], NULL);CHKERRQ(ierr); 3339de99aefSMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 3349de99aefSMatthew G. Knepley PetscFV fv = (PetscFV) obj; 3359de99aefSMatthew G. Knepley 3369de99aefSMatthew G. Knepley ierr = PetscFVGetQuadrature(fv, &q);CHKERRQ(ierr); 3379de99aefSMatthew G. Knepley Nb = 1; 3389de99aefSMatthew G. Knepley ierr = PetscFVGetNumComponents(fv, &Nc);CHKERRQ(ierr); 3396c1a3d01SMatthew G. Knepley ierr = PetscFVGetDefaultTabulation(fv, &prob->basis[f], &prob->basisDer[f], NULL);CHKERRQ(ierr); 340abac5ca0SMatthew G. Knepley } else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", f); 341194d53e6SMatthew G. Knepley prob->off[f+1] = Nc + prob->off[f]; 342194d53e6SMatthew G. Knepley prob->offDer[f+1] = Nc*dim + prob->offDer[f]; 3439de99aefSMatthew G. Knepley if (q) {ierr = PetscQuadratureGetData(q, NULL, &Nq, NULL, NULL);CHKERRQ(ierr);} 3442764a2aaSMatthew G. Knepley NqMax = PetscMax(NqMax, Nq); 3452764a2aaSMatthew G. Knepley NcMax = PetscMax(NcMax, Nc); 3462764a2aaSMatthew G. Knepley prob->totDim += Nb*Nc; 3472764a2aaSMatthew G. Knepley prob->totComp += Nc; 3482764a2aaSMatthew G. Knepley if (feBd) { 3492764a2aaSMatthew G. Knepley ierr = PetscFEGetDimension(feBd, &Nb);CHKERRQ(ierr); 3502764a2aaSMatthew G. Knepley ierr = PetscFEGetNumComponents(feBd, &Nc);CHKERRQ(ierr); 3512764a2aaSMatthew G. Knepley ierr = PetscFEGetDefaultTabulation(feBd, &prob->basisBd[f], &prob->basisDerBd[f], NULL);CHKERRQ(ierr); 3522764a2aaSMatthew G. Knepley prob->totDimBd += Nb*Nc; 353194d53e6SMatthew G. Knepley prob->offBd[f+1] = Nc + prob->offBd[f]; 354194d53e6SMatthew G. Knepley prob->offDerBd[f+1] = Nc*dim + prob->offDerBd[f]; 3552764a2aaSMatthew G. Knepley } 3562764a2aaSMatthew G. Knepley } 3572764a2aaSMatthew G. Knepley work = PetscMax(prob->totComp*dim, PetscSqr(NcMax*dim)); 3582764a2aaSMatthew G. Knepley /* Allocate works space */ 3592764a2aaSMatthew 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); 3602764a2aaSMatthew G. Knepley ierr = PetscMalloc6(NqMax*NcMax,&prob->f0,NqMax*NcMax*dim,&prob->f1,NqMax*NcMax*NcMax,&prob->g0,NqMax*NcMax*NcMax*dim,&prob->g1,NqMax*NcMax*NcMax*dim,&prob->g2,NqMax*NcMax*NcMax*dim*dim,&prob->g3);CHKERRQ(ierr); 3612764a2aaSMatthew G. Knepley if (prob->ops->setup) {ierr = (*prob->ops->setup)(prob);CHKERRQ(ierr);} 3622764a2aaSMatthew G. Knepley prob->setup = PETSC_TRUE; 3632764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 3642764a2aaSMatthew G. Knepley } 3652764a2aaSMatthew G. Knepley 3662764a2aaSMatthew G. Knepley #undef __FUNCT__ 3672764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroyStructs_Static" 3682764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSDestroyStructs_Static(PetscDS prob) 3692764a2aaSMatthew G. Knepley { 3702764a2aaSMatthew G. Knepley PetscErrorCode ierr; 3712764a2aaSMatthew G. Knepley 3722764a2aaSMatthew G. Knepley PetscFunctionBegin; 373194d53e6SMatthew G. Knepley ierr = PetscFree4(prob->off,prob->offDer,prob->offBd,prob->offDerBd);CHKERRQ(ierr); 3742764a2aaSMatthew G. Knepley ierr = PetscFree4(prob->basis,prob->basisDer,prob->basisBd,prob->basisDerBd);CHKERRQ(ierr); 3752764a2aaSMatthew G. Knepley ierr = PetscFree5(prob->u,prob->u_t,prob->u_x,prob->x,prob->refSpaceDer);CHKERRQ(ierr); 3762764a2aaSMatthew G. Knepley ierr = PetscFree6(prob->f0,prob->f1,prob->g0,prob->g1,prob->g2,prob->g3);CHKERRQ(ierr); 3772764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 3782764a2aaSMatthew G. Knepley } 3792764a2aaSMatthew G. Knepley 3802764a2aaSMatthew G. Knepley #undef __FUNCT__ 3812764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSEnlarge_Static" 3822764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSEnlarge_Static(PetscDS prob, PetscInt NfNew) 3832764a2aaSMatthew G. Knepley { 3842764a2aaSMatthew G. Knepley PetscObject *tmpd, *tmpdbd; 385a6cbbb48SMatthew G. Knepley PetscBool *tmpi, *tmpa; 386194d53e6SMatthew G. Knepley PetscPointFunc *tmpobj, *tmpf, *tmpg; 387194d53e6SMatthew G. Knepley PetscBdPointFunc *tmpfbd, *tmpgbd; 388194d53e6SMatthew G. Knepley PetscRiemannFunc *tmpr; 3890c2f2876SMatthew G. Knepley void **tmpctx; 390a6cbbb48SMatthew G. Knepley PetscInt Nf = prob->Nf, f, i; 3912764a2aaSMatthew G. Knepley PetscErrorCode ierr; 3922764a2aaSMatthew G. Knepley 3932764a2aaSMatthew G. Knepley PetscFunctionBegin; 3942764a2aaSMatthew G. Knepley if (Nf >= NfNew) PetscFunctionReturn(0); 3952764a2aaSMatthew G. Knepley prob->setup = PETSC_FALSE; 3962764a2aaSMatthew G. Knepley ierr = PetscDSDestroyStructs_Static(prob);CHKERRQ(ierr); 397a6cbbb48SMatthew G. Knepley ierr = PetscMalloc4(NfNew, &tmpd, NfNew, &tmpdbd, NfNew, &tmpi, NfNew*2, &tmpa);CHKERRQ(ierr); 398a6cbbb48SMatthew G. Knepley for (f = 0; f < Nf; ++f) {tmpd[f] = prob->disc[f]; tmpdbd[f] = prob->discBd[f]; tmpi[f] = prob->implicit[f]; for (i = 0; i < 2; ++i) tmpa[f*2+i] = prob->adjacency[f*2+i];} 399a6cbbb48SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) {ierr = PetscContainerCreate(PetscObjectComm((PetscObject) prob), (PetscContainer *) &tmpd[f]);CHKERRQ(ierr); 400a6cbbb48SMatthew G. Knepley tmpdbd[f] = NULL; tmpi[f] = PETSC_TRUE; tmpa[f*2+0] = PETSC_FALSE; tmpa[f*2+1] = PETSC_TRUE;} 401a6cbbb48SMatthew G. Knepley ierr = PetscFree4(prob->disc, prob->discBd, prob->implicit, prob->adjacency);CHKERRQ(ierr); 4022764a2aaSMatthew G. Knepley prob->Nf = NfNew; 4032764a2aaSMatthew G. Knepley prob->disc = tmpd; 404a6cbbb48SMatthew G. Knepley prob->discBd = tmpdbd; 405249df284SMatthew G. Knepley prob->implicit = tmpi; 406a6cbbb48SMatthew G. Knepley prob->adjacency = tmpa; 4070c2f2876SMatthew G. Knepley ierr = PetscCalloc5(NfNew, &tmpobj, NfNew*2, &tmpf, NfNew*NfNew*4, &tmpg, NfNew, &tmpr, NfNew, &tmpctx);CHKERRQ(ierr); 4082764a2aaSMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpobj[f] = prob->obj[f]; 4092764a2aaSMatthew G. Knepley for (f = 0; f < Nf*2; ++f) tmpf[f] = prob->f[f]; 4102764a2aaSMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpg[f] = prob->g[f]; 4110c2f2876SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpr[f] = prob->r[f]; 4120c2f2876SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpctx[f] = prob->ctx[f]; 4132764a2aaSMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpobj[f] = NULL; 4142764a2aaSMatthew G. Knepley for (f = Nf*2; f < NfNew*2; ++f) tmpf[f] = NULL; 4152764a2aaSMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpg[f] = NULL; 4160c2f2876SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpr[f] = NULL; 4170c2f2876SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpctx[f] = NULL; 4180c2f2876SMatthew G. Knepley ierr = PetscFree5(prob->obj, prob->f, prob->g, prob->r, prob->ctx);CHKERRQ(ierr); 4192764a2aaSMatthew G. Knepley prob->obj = tmpobj; 4202764a2aaSMatthew G. Knepley prob->f = tmpf; 4212764a2aaSMatthew G. Knepley prob->g = tmpg; 4220c2f2876SMatthew G. Knepley prob->r = tmpr; 4230c2f2876SMatthew G. Knepley prob->ctx = tmpctx; 4242764a2aaSMatthew G. Knepley ierr = PetscCalloc2(NfNew*2, &tmpfbd, NfNew*NfNew*4, &tmpgbd);CHKERRQ(ierr); 4252764a2aaSMatthew G. Knepley for (f = 0; f < Nf*2; ++f) tmpfbd[f] = prob->fBd[f]; 4262764a2aaSMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpgbd[f] = prob->gBd[f]; 4272764a2aaSMatthew G. Knepley for (f = Nf*2; f < NfNew*2; ++f) tmpfbd[f] = NULL; 4282764a2aaSMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgbd[f] = NULL; 4292764a2aaSMatthew G. Knepley ierr = PetscFree2(prob->fBd, prob->gBd);CHKERRQ(ierr); 4302764a2aaSMatthew G. Knepley prob->fBd = tmpfbd; 4312764a2aaSMatthew G. Knepley prob->gBd = tmpgbd; 4322764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4332764a2aaSMatthew G. Knepley } 4342764a2aaSMatthew G. Knepley 4352764a2aaSMatthew G. Knepley #undef __FUNCT__ 4362764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroy" 4372764a2aaSMatthew G. Knepley /*@ 4382764a2aaSMatthew G. Knepley PetscDSDestroy - Destroys a PetscDS object 4392764a2aaSMatthew G. Knepley 4402764a2aaSMatthew G. Knepley Collective on PetscDS 4412764a2aaSMatthew G. Knepley 4422764a2aaSMatthew G. Knepley Input Parameter: 4432764a2aaSMatthew G. Knepley . prob - the PetscDS object to destroy 4442764a2aaSMatthew G. Knepley 4452764a2aaSMatthew G. Knepley Level: developer 4462764a2aaSMatthew G. Knepley 4472764a2aaSMatthew G. Knepley .seealso PetscDSView() 4482764a2aaSMatthew G. Knepley @*/ 4492764a2aaSMatthew G. Knepley PetscErrorCode PetscDSDestroy(PetscDS *prob) 4502764a2aaSMatthew G. Knepley { 4512764a2aaSMatthew G. Knepley PetscInt f; 4522764a2aaSMatthew G. Knepley PetscErrorCode ierr; 4532764a2aaSMatthew G. Knepley 4542764a2aaSMatthew G. Knepley PetscFunctionBegin; 4552764a2aaSMatthew G. Knepley if (!*prob) PetscFunctionReturn(0); 4562764a2aaSMatthew G. Knepley PetscValidHeaderSpecific((*prob), PETSCDS_CLASSID, 1); 4572764a2aaSMatthew G. Knepley 4582764a2aaSMatthew G. Knepley if (--((PetscObject)(*prob))->refct > 0) {*prob = 0; PetscFunctionReturn(0);} 4592764a2aaSMatthew G. Knepley ((PetscObject) (*prob))->refct = 0; 4602764a2aaSMatthew G. Knepley ierr = PetscDSDestroyStructs_Static(*prob);CHKERRQ(ierr); 4612764a2aaSMatthew G. Knepley for (f = 0; f < (*prob)->Nf; ++f) { 4622764a2aaSMatthew G. Knepley ierr = PetscObjectDereference((*prob)->disc[f]);CHKERRQ(ierr); 4632764a2aaSMatthew G. Knepley ierr = PetscObjectDereference((*prob)->discBd[f]);CHKERRQ(ierr); 4642764a2aaSMatthew G. Knepley } 465a6cbbb48SMatthew G. Knepley ierr = PetscFree4((*prob)->disc, (*prob)->discBd, (*prob)->implicit, (*prob)->adjacency);CHKERRQ(ierr); 4660c2f2876SMatthew G. Knepley ierr = PetscFree5((*prob)->obj,(*prob)->f,(*prob)->g,(*prob)->r,(*prob)->ctx);CHKERRQ(ierr); 4672764a2aaSMatthew G. Knepley ierr = PetscFree2((*prob)->fBd,(*prob)->gBd);CHKERRQ(ierr); 4682764a2aaSMatthew G. Knepley if ((*prob)->ops->destroy) {ierr = (*(*prob)->ops->destroy)(*prob);CHKERRQ(ierr);} 4692764a2aaSMatthew G. Knepley ierr = PetscHeaderDestroy(prob);CHKERRQ(ierr); 4702764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4712764a2aaSMatthew G. Knepley } 4722764a2aaSMatthew G. Knepley 4732764a2aaSMatthew G. Knepley #undef __FUNCT__ 4742764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSCreate" 4752764a2aaSMatthew G. Knepley /*@ 4762764a2aaSMatthew G. Knepley PetscDSCreate - Creates an empty PetscDS object. The type can then be set with PetscDSSetType(). 4772764a2aaSMatthew G. Knepley 4782764a2aaSMatthew G. Knepley Collective on MPI_Comm 4792764a2aaSMatthew G. Knepley 4802764a2aaSMatthew G. Knepley Input Parameter: 4812764a2aaSMatthew G. Knepley . comm - The communicator for the PetscDS object 4822764a2aaSMatthew G. Knepley 4832764a2aaSMatthew G. Knepley Output Parameter: 4842764a2aaSMatthew G. Knepley . prob - The PetscDS object 4852764a2aaSMatthew G. Knepley 4862764a2aaSMatthew G. Knepley Level: beginner 4872764a2aaSMatthew G. Knepley 4882764a2aaSMatthew G. Knepley .seealso: PetscDSSetType(), PETSCDSBASIC 4892764a2aaSMatthew G. Knepley @*/ 4902764a2aaSMatthew G. Knepley PetscErrorCode PetscDSCreate(MPI_Comm comm, PetscDS *prob) 4912764a2aaSMatthew G. Knepley { 4922764a2aaSMatthew G. Knepley PetscDS p; 4932764a2aaSMatthew G. Knepley PetscErrorCode ierr; 4942764a2aaSMatthew G. Knepley 4952764a2aaSMatthew G. Knepley PetscFunctionBegin; 4962764a2aaSMatthew G. Knepley PetscValidPointer(prob, 2); 4972764a2aaSMatthew G. Knepley *prob = NULL; 4982764a2aaSMatthew G. Knepley ierr = PetscDSInitializePackage();CHKERRQ(ierr); 4992764a2aaSMatthew G. Knepley 50073107ff1SLisandro Dalcin ierr = PetscHeaderCreate(p, PETSCDS_CLASSID, "PetscDS", "Discrete System", "PetscDS", comm, PetscDSDestroy, PetscDSView);CHKERRQ(ierr); 5012764a2aaSMatthew G. Knepley 5022764a2aaSMatthew G. Knepley p->Nf = 0; 5032764a2aaSMatthew G. Knepley p->setup = PETSC_FALSE; 5042764a2aaSMatthew G. Knepley 5052764a2aaSMatthew G. Knepley *prob = p; 5062764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5072764a2aaSMatthew G. Knepley } 5082764a2aaSMatthew G. Knepley 5092764a2aaSMatthew G. Knepley #undef __FUNCT__ 5102764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetNumFields" 511bc4ae4beSMatthew G. Knepley /*@ 512bc4ae4beSMatthew G. Knepley PetscDSGetNumFields - Returns the number of fields in the DS 513bc4ae4beSMatthew G. Knepley 514bc4ae4beSMatthew G. Knepley Not collective 515bc4ae4beSMatthew G. Knepley 516bc4ae4beSMatthew G. Knepley Input Parameter: 517bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 518bc4ae4beSMatthew G. Knepley 519bc4ae4beSMatthew G. Knepley Output Parameter: 520bc4ae4beSMatthew G. Knepley . Nf - The number of fields 521bc4ae4beSMatthew G. Knepley 522bc4ae4beSMatthew G. Knepley Level: beginner 523bc4ae4beSMatthew G. Knepley 524bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetSpatialDimension(), PetscDSCreate() 525bc4ae4beSMatthew G. Knepley @*/ 5262764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetNumFields(PetscDS prob, PetscInt *Nf) 5272764a2aaSMatthew G. Knepley { 5282764a2aaSMatthew G. Knepley PetscFunctionBegin; 5292764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 5302764a2aaSMatthew G. Knepley PetscValidPointer(Nf, 2); 5312764a2aaSMatthew G. Knepley *Nf = prob->Nf; 5322764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5332764a2aaSMatthew G. Knepley } 5342764a2aaSMatthew G. Knepley 5352764a2aaSMatthew G. Knepley #undef __FUNCT__ 5362764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetSpatialDimension" 537bc4ae4beSMatthew G. Knepley /*@ 538bc4ae4beSMatthew G. Knepley PetscDSGetSpatialDimension - Returns the spatial dimension of the DS 539bc4ae4beSMatthew G. Knepley 540bc4ae4beSMatthew G. Knepley Not collective 541bc4ae4beSMatthew G. Knepley 542bc4ae4beSMatthew G. Knepley Input Parameter: 543bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 544bc4ae4beSMatthew G. Knepley 545bc4ae4beSMatthew G. Knepley Output Parameter: 546bc4ae4beSMatthew G. Knepley . dim - The spatial dimension 547bc4ae4beSMatthew G. Knepley 548bc4ae4beSMatthew G. Knepley Level: beginner 549bc4ae4beSMatthew G. Knepley 550bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 551bc4ae4beSMatthew G. Knepley @*/ 5522764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetSpatialDimension(PetscDS prob, PetscInt *dim) 5532764a2aaSMatthew G. Knepley { 5542764a2aaSMatthew G. Knepley PetscErrorCode ierr; 5552764a2aaSMatthew G. Knepley 5562764a2aaSMatthew G. Knepley PetscFunctionBegin; 5572764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 5582764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 5592764a2aaSMatthew G. Knepley *dim = 0; 5609de99aefSMatthew G. Knepley if (prob->Nf) { 5619de99aefSMatthew G. Knepley PetscObject obj; 5629de99aefSMatthew G. Knepley PetscClassId id; 5639de99aefSMatthew G. Knepley 5649de99aefSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, 0, &obj);CHKERRQ(ierr); 5659de99aefSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 5669de99aefSMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEGetSpatialDimension((PetscFE) obj, dim);CHKERRQ(ierr);} 5679de99aefSMatthew G. Knepley else if (id == PETSCFV_CLASSID) {ierr = PetscFVGetSpatialDimension((PetscFV) obj, dim);CHKERRQ(ierr);} 5689de99aefSMatthew G. Knepley else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", 0); 5699de99aefSMatthew G. Knepley } 5702764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5712764a2aaSMatthew G. Knepley } 5722764a2aaSMatthew G. Knepley 5732764a2aaSMatthew G. Knepley #undef __FUNCT__ 5742764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalDimension" 575bc4ae4beSMatthew G. Knepley /*@ 576bc4ae4beSMatthew G. Knepley PetscDSGetTotalDimension - Returns the total size of the approximation space for this system 577bc4ae4beSMatthew G. Knepley 578bc4ae4beSMatthew G. Knepley Not collective 579bc4ae4beSMatthew G. Knepley 580bc4ae4beSMatthew G. Knepley Input Parameter: 581bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 582bc4ae4beSMatthew G. Knepley 583bc4ae4beSMatthew G. Knepley Output Parameter: 584bc4ae4beSMatthew G. Knepley . dim - The total problem dimension 585bc4ae4beSMatthew G. Knepley 586bc4ae4beSMatthew G. Knepley Level: beginner 587bc4ae4beSMatthew G. Knepley 588bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 589bc4ae4beSMatthew G. Knepley @*/ 5902764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalDimension(PetscDS prob, PetscInt *dim) 5912764a2aaSMatthew G. Knepley { 5922764a2aaSMatthew G. Knepley PetscErrorCode ierr; 5932764a2aaSMatthew G. Knepley 5942764a2aaSMatthew G. Knepley PetscFunctionBegin; 5952764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 5962764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 5972764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 5982764a2aaSMatthew G. Knepley *dim = prob->totDim; 5992764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6002764a2aaSMatthew G. Knepley } 6012764a2aaSMatthew G. Knepley 6022764a2aaSMatthew G. Knepley #undef __FUNCT__ 6032764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalBdDimension" 604bc4ae4beSMatthew G. Knepley /*@ 605c3ac4435SMatthew G. Knepley PetscDSGetTotalBdDimension - Returns the total size of the boundary approximation space for this system 606bc4ae4beSMatthew G. Knepley 607bc4ae4beSMatthew G. Knepley Not collective 608bc4ae4beSMatthew G. Knepley 609bc4ae4beSMatthew G. Knepley Input Parameter: 610bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 611bc4ae4beSMatthew G. Knepley 612bc4ae4beSMatthew G. Knepley Output Parameter: 613bc4ae4beSMatthew G. Knepley . dim - The total boundary problem dimension 614bc4ae4beSMatthew G. Knepley 615bc4ae4beSMatthew G. Knepley Level: beginner 616bc4ae4beSMatthew G. Knepley 617bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 618bc4ae4beSMatthew G. Knepley @*/ 6192764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalBdDimension(PetscDS prob, PetscInt *dim) 6202764a2aaSMatthew G. Knepley { 6212764a2aaSMatthew G. Knepley PetscErrorCode ierr; 6222764a2aaSMatthew G. Knepley 6232764a2aaSMatthew G. Knepley PetscFunctionBegin; 6242764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6252764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 6262764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 6272764a2aaSMatthew G. Knepley *dim = prob->totDimBd; 6282764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6292764a2aaSMatthew G. Knepley } 6302764a2aaSMatthew G. Knepley 6312764a2aaSMatthew G. Knepley #undef __FUNCT__ 6322764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalComponents" 633bc4ae4beSMatthew G. Knepley /*@ 634bc4ae4beSMatthew G. Knepley PetscDSGetTotalComponents - Returns the total number of components in this system 635bc4ae4beSMatthew G. Knepley 636bc4ae4beSMatthew G. Knepley Not collective 637bc4ae4beSMatthew G. Knepley 638bc4ae4beSMatthew G. Knepley Input Parameter: 639bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 640bc4ae4beSMatthew G. Knepley 641bc4ae4beSMatthew G. Knepley Output Parameter: 642bc4ae4beSMatthew G. Knepley . dim - The total number of components 643bc4ae4beSMatthew G. Knepley 644bc4ae4beSMatthew G. Knepley Level: beginner 645bc4ae4beSMatthew G. Knepley 646bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 647bc4ae4beSMatthew G. Knepley @*/ 6482764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalComponents(PetscDS prob, PetscInt *Nc) 6492764a2aaSMatthew G. Knepley { 6502764a2aaSMatthew G. Knepley PetscErrorCode ierr; 6512764a2aaSMatthew G. Knepley 6522764a2aaSMatthew G. Knepley PetscFunctionBegin; 6532764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6542764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 6552764a2aaSMatthew G. Knepley PetscValidPointer(Nc, 2); 6562764a2aaSMatthew G. Knepley *Nc = prob->totComp; 6572764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6582764a2aaSMatthew G. Knepley } 6592764a2aaSMatthew G. Knepley 6602764a2aaSMatthew G. Knepley #undef __FUNCT__ 6612764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetDiscretization" 662bc4ae4beSMatthew G. Knepley /*@ 663bc4ae4beSMatthew G. Knepley PetscDSGetDiscretization - Returns the discretization object for the given field 664bc4ae4beSMatthew G. Knepley 665bc4ae4beSMatthew G. Knepley Not collective 666bc4ae4beSMatthew G. Knepley 667bc4ae4beSMatthew G. Knepley Input Parameters: 668bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 669bc4ae4beSMatthew G. Knepley - f - The field number 670bc4ae4beSMatthew G. Knepley 671bc4ae4beSMatthew G. Knepley Output Parameter: 672bc4ae4beSMatthew G. Knepley . disc - The discretization object 673bc4ae4beSMatthew G. Knepley 674bc4ae4beSMatthew G. Knepley Level: beginner 675bc4ae4beSMatthew G. Knepley 676bc4ae4beSMatthew G. Knepley .seealso: PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 677bc4ae4beSMatthew G. Knepley @*/ 6782764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetDiscretization(PetscDS prob, PetscInt f, PetscObject *disc) 6792764a2aaSMatthew G. Knepley { 6802764a2aaSMatthew G. Knepley PetscFunctionBegin; 6812764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6822764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 6832764a2aaSMatthew 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); 6842764a2aaSMatthew G. Knepley *disc = prob->disc[f]; 6852764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6862764a2aaSMatthew G. Knepley } 6872764a2aaSMatthew G. Knepley 6882764a2aaSMatthew G. Knepley #undef __FUNCT__ 6892764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdDiscretization" 690bc4ae4beSMatthew G. Knepley /*@ 691bc4ae4beSMatthew G. Knepley PetscDSGetBdDiscretization - Returns the boundary discretization object for the given field 692bc4ae4beSMatthew G. Knepley 693bc4ae4beSMatthew G. Knepley Not collective 694bc4ae4beSMatthew G. Knepley 695bc4ae4beSMatthew G. Knepley Input Parameters: 696bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 697bc4ae4beSMatthew G. Knepley - f - The field number 698bc4ae4beSMatthew G. Knepley 699bc4ae4beSMatthew G. Knepley Output Parameter: 700bc4ae4beSMatthew G. Knepley . disc - The boundary discretization object 701bc4ae4beSMatthew G. Knepley 702bc4ae4beSMatthew G. Knepley Level: beginner 703bc4ae4beSMatthew G. Knepley 704bc4ae4beSMatthew G. Knepley .seealso: PetscDSSetBdDiscretization(), PetscDSAddBdDiscretization(), PetscDSGetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 705bc4ae4beSMatthew G. Knepley @*/ 7062764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdDiscretization(PetscDS prob, PetscInt f, PetscObject *disc) 7072764a2aaSMatthew G. Knepley { 7082764a2aaSMatthew G. Knepley PetscFunctionBegin; 7092764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7102764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 7112764a2aaSMatthew 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); 7122764a2aaSMatthew G. Knepley *disc = prob->discBd[f]; 7132764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7142764a2aaSMatthew G. Knepley } 7152764a2aaSMatthew G. Knepley 7162764a2aaSMatthew G. Knepley #undef __FUNCT__ 7172764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetDiscretization" 718bc4ae4beSMatthew G. Knepley /*@ 719bc4ae4beSMatthew G. Knepley PetscDSSetDiscretization - Sets the discretization object for the given field 720bc4ae4beSMatthew G. Knepley 721bc4ae4beSMatthew G. Knepley Not collective 722bc4ae4beSMatthew G. Knepley 723bc4ae4beSMatthew G. Knepley Input Parameters: 724bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 725bc4ae4beSMatthew G. Knepley . f - The field number 726bc4ae4beSMatthew G. Knepley - disc - The discretization object 727bc4ae4beSMatthew G. Knepley 728bc4ae4beSMatthew G. Knepley Level: beginner 729bc4ae4beSMatthew G. Knepley 730bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 731bc4ae4beSMatthew G. Knepley @*/ 7322764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetDiscretization(PetscDS prob, PetscInt f, PetscObject disc) 7332764a2aaSMatthew G. Knepley { 7342764a2aaSMatthew G. Knepley PetscErrorCode ierr; 7352764a2aaSMatthew G. Knepley 7362764a2aaSMatthew G. Knepley PetscFunctionBegin; 7372764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7382764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 7392764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 7402764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 7412764a2aaSMatthew G. Knepley if (prob->disc[f]) {ierr = PetscObjectDereference(prob->disc[f]);CHKERRQ(ierr);} 7422764a2aaSMatthew G. Knepley prob->disc[f] = disc; 7432764a2aaSMatthew G. Knepley ierr = PetscObjectReference(disc);CHKERRQ(ierr); 744249df284SMatthew G. Knepley { 745249df284SMatthew G. Knepley PetscClassId id; 746249df284SMatthew G. Knepley 747249df284SMatthew G. Knepley ierr = PetscObjectGetClassId(disc, &id);CHKERRQ(ierr); 748a6cbbb48SMatthew G. Knepley if (id == PETSCFV_CLASSID) { 749a6cbbb48SMatthew G. Knepley prob->implicit[f] = PETSC_FALSE; 750a6cbbb48SMatthew G. Knepley prob->adjacency[f*2+0] = PETSC_TRUE; 751a6cbbb48SMatthew G. Knepley prob->adjacency[f*2+1] = PETSC_FALSE; 752a6cbbb48SMatthew G. Knepley } 753249df284SMatthew G. Knepley } 7542764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7552764a2aaSMatthew G. Knepley } 7562764a2aaSMatthew G. Knepley 7572764a2aaSMatthew G. Knepley #undef __FUNCT__ 7582764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdDiscretization" 759bc4ae4beSMatthew G. Knepley /*@ 760bc4ae4beSMatthew G. Knepley PetscDSSetBdDiscretization - Sets the boundary discretization object for the given field 761bc4ae4beSMatthew G. Knepley 762bc4ae4beSMatthew G. Knepley Not collective 763bc4ae4beSMatthew G. Knepley 764bc4ae4beSMatthew G. Knepley Input Parameters: 765bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 766bc4ae4beSMatthew G. Knepley . f - The field number 767bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object 768bc4ae4beSMatthew G. Knepley 769bc4ae4beSMatthew G. Knepley Level: beginner 770bc4ae4beSMatthew G. Knepley 771bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetBdDiscretization(), PetscDSAddBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 772bc4ae4beSMatthew G. Knepley @*/ 7732764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdDiscretization(PetscDS prob, PetscInt f, PetscObject disc) 7742764a2aaSMatthew G. Knepley { 7752764a2aaSMatthew G. Knepley PetscErrorCode ierr; 7762764a2aaSMatthew G. Knepley 7772764a2aaSMatthew G. Knepley PetscFunctionBegin; 7782764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7792764a2aaSMatthew G. Knepley if (disc) PetscValidPointer(disc, 3); 7802764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 7812764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 7822764a2aaSMatthew G. Knepley if (prob->discBd[f]) {ierr = PetscObjectDereference(prob->discBd[f]);CHKERRQ(ierr);} 7832764a2aaSMatthew G. Knepley prob->discBd[f] = disc; 7842764a2aaSMatthew G. Knepley ierr = PetscObjectReference(disc);CHKERRQ(ierr); 7852764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7862764a2aaSMatthew G. Knepley } 7872764a2aaSMatthew G. Knepley 7882764a2aaSMatthew G. Knepley #undef __FUNCT__ 7892764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSAddDiscretization" 790bc4ae4beSMatthew G. Knepley /*@ 791bc4ae4beSMatthew G. Knepley PetscDSAddDiscretization - Adds a discretization object 792bc4ae4beSMatthew G. Knepley 793bc4ae4beSMatthew G. Knepley Not collective 794bc4ae4beSMatthew G. Knepley 795bc4ae4beSMatthew G. Knepley Input Parameters: 796bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 797bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object 798bc4ae4beSMatthew G. Knepley 799bc4ae4beSMatthew G. Knepley Level: beginner 800bc4ae4beSMatthew G. Knepley 801bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSSetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 802bc4ae4beSMatthew G. Knepley @*/ 8032764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddDiscretization(PetscDS prob, PetscObject disc) 8042764a2aaSMatthew G. Knepley { 8052764a2aaSMatthew G. Knepley PetscErrorCode ierr; 8062764a2aaSMatthew G. Knepley 8072764a2aaSMatthew G. Knepley PetscFunctionBegin; 8082764a2aaSMatthew G. Knepley ierr = PetscDSSetDiscretization(prob, prob->Nf, disc);CHKERRQ(ierr); 8092764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8102764a2aaSMatthew G. Knepley } 8112764a2aaSMatthew G. Knepley 8122764a2aaSMatthew G. Knepley #undef __FUNCT__ 8132764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSAddBdDiscretization" 814bc4ae4beSMatthew G. Knepley /*@ 815bc4ae4beSMatthew G. Knepley PetscDSAddBdDiscretization - Adds a boundary discretization object 816bc4ae4beSMatthew G. Knepley 817bc4ae4beSMatthew G. Knepley Not collective 818bc4ae4beSMatthew G. Knepley 819bc4ae4beSMatthew G. Knepley Input Parameters: 820bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 821bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object 822bc4ae4beSMatthew G. Knepley 823bc4ae4beSMatthew G. Knepley Level: beginner 824bc4ae4beSMatthew G. Knepley 825bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetBdDiscretization(), PetscDSSetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 826bc4ae4beSMatthew G. Knepley @*/ 8272764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddBdDiscretization(PetscDS prob, PetscObject disc) 8282764a2aaSMatthew G. Knepley { 8292764a2aaSMatthew G. Knepley PetscErrorCode ierr; 8302764a2aaSMatthew G. Knepley 8312764a2aaSMatthew G. Knepley PetscFunctionBegin; 8322764a2aaSMatthew G. Knepley ierr = PetscDSSetBdDiscretization(prob, prob->Nf, disc);CHKERRQ(ierr); 8332764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8342764a2aaSMatthew G. Knepley } 8352764a2aaSMatthew G. Knepley 8362764a2aaSMatthew G. Knepley #undef __FUNCT__ 837249df284SMatthew G. Knepley #define __FUNCT__ "PetscDSGetImplicit" 838249df284SMatthew G. Knepley /*@ 839249df284SMatthew G. Knepley PetscDSGetImplicit - Returns the flag for implicit solve for this field. This is just a guide for IMEX 840249df284SMatthew G. Knepley 841249df284SMatthew G. Knepley Not collective 842249df284SMatthew G. Knepley 843249df284SMatthew G. Knepley Input Parameters: 844249df284SMatthew G. Knepley + prob - The PetscDS object 845249df284SMatthew G. Knepley - f - The field number 846249df284SMatthew G. Knepley 847249df284SMatthew G. Knepley Output Parameter: 848249df284SMatthew G. Knepley . implicit - The flag indicating what kind of solve to use for this field 849249df284SMatthew G. Knepley 850249df284SMatthew G. Knepley Level: developer 851249df284SMatthew G. Knepley 852249df284SMatthew G. Knepley .seealso: PetscDSSetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 853249df284SMatthew G. Knepley @*/ 854249df284SMatthew G. Knepley PetscErrorCode PetscDSGetImplicit(PetscDS prob, PetscInt f, PetscBool *implicit) 855249df284SMatthew G. Knepley { 856249df284SMatthew G. Knepley PetscFunctionBegin; 857249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 858249df284SMatthew G. Knepley PetscValidPointer(implicit, 3); 859249df284SMatthew 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); 860249df284SMatthew G. Knepley *implicit = prob->implicit[f]; 861249df284SMatthew G. Knepley PetscFunctionReturn(0); 862249df284SMatthew G. Knepley } 863249df284SMatthew G. Knepley 864249df284SMatthew G. Knepley #undef __FUNCT__ 865249df284SMatthew G. Knepley #define __FUNCT__ "PetscDSSetImplicit" 866249df284SMatthew G. Knepley /*@ 867249df284SMatthew G. Knepley PetscDSSetImplicit - Set the flag for implicit solve for this field. This is just a guide for IMEX 868249df284SMatthew G. Knepley 869249df284SMatthew G. Knepley Not collective 870249df284SMatthew G. Knepley 871249df284SMatthew G. Knepley Input Parameters: 872249df284SMatthew G. Knepley + prob - The PetscDS object 873249df284SMatthew G. Knepley . f - The field number 874249df284SMatthew G. Knepley - implicit - The flag indicating what kind of solve to use for this field 875249df284SMatthew G. Knepley 876249df284SMatthew G. Knepley Level: developer 877249df284SMatthew G. Knepley 878249df284SMatthew G. Knepley .seealso: PetscDSGetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 879249df284SMatthew G. Knepley @*/ 880249df284SMatthew G. Knepley PetscErrorCode PetscDSSetImplicit(PetscDS prob, PetscInt f, PetscBool implicit) 881249df284SMatthew G. Knepley { 882249df284SMatthew G. Knepley PetscFunctionBegin; 883249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 884249df284SMatthew 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); 885249df284SMatthew G. Knepley prob->implicit[f] = implicit; 886249df284SMatthew G. Knepley PetscFunctionReturn(0); 887249df284SMatthew G. Knepley } 888249df284SMatthew G. Knepley 889249df284SMatthew G. Knepley #undef __FUNCT__ 890a6cbbb48SMatthew G. Knepley #define __FUNCT__ "PetscDSGetAdjacency" 891a6cbbb48SMatthew G. Knepley /*@ 892a6cbbb48SMatthew G. Knepley PetscDSGetAdjacency - Returns the flags for determining variable influence 893a6cbbb48SMatthew G. Knepley 894a6cbbb48SMatthew G. Knepley Not collective 895a6cbbb48SMatthew G. Knepley 896a6cbbb48SMatthew G. Knepley Input Parameters: 897a6cbbb48SMatthew G. Knepley + prob - The PetscDS object 898a6cbbb48SMatthew G. Knepley - f - The field number 899a6cbbb48SMatthew G. Knepley 900a6cbbb48SMatthew G. Knepley Output Parameter: 901a6cbbb48SMatthew G. Knepley + useCone - Flag for variable influence starting with the cone operation 902a6cbbb48SMatthew G. Knepley - useClosure - Flag for variable influence using transitive closure 903a6cbbb48SMatthew G. Knepley 904a6cbbb48SMatthew G. Knepley Note: See the discussion in DMPlexGetAdjacencyUseCone() and DMPlexGetAdjacencyUseClosure() 905a6cbbb48SMatthew G. Knepley 906a6cbbb48SMatthew G. Knepley Level: developer 907a6cbbb48SMatthew G. Knepley 908a6cbbb48SMatthew G. Knepley .seealso: PetscDSSetAdjacency(), DMPlexGetAdjacencyUseCone(), DMPlexGetAdjacencyUseClosure(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 909a6cbbb48SMatthew G. Knepley @*/ 910a6cbbb48SMatthew G. Knepley PetscErrorCode PetscDSGetAdjacency(PetscDS prob, PetscInt f, PetscBool *useCone, PetscBool *useClosure) 911a6cbbb48SMatthew G. Knepley { 912a6cbbb48SMatthew G. Knepley PetscFunctionBegin; 913a6cbbb48SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 914a6cbbb48SMatthew G. Knepley PetscValidPointer(useCone, 3); 915a6cbbb48SMatthew G. Knepley PetscValidPointer(useClosure, 4); 916a6cbbb48SMatthew 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); 917a6cbbb48SMatthew G. Knepley *useCone = prob->adjacency[f*2+0]; 918a6cbbb48SMatthew G. Knepley *useClosure = prob->adjacency[f*2+1]; 919a6cbbb48SMatthew G. Knepley PetscFunctionReturn(0); 920a6cbbb48SMatthew G. Knepley } 921a6cbbb48SMatthew G. Knepley 922a6cbbb48SMatthew G. Knepley #undef __FUNCT__ 923a6cbbb48SMatthew G. Knepley #define __FUNCT__ "PetscDSSetAdjacency" 924a6cbbb48SMatthew G. Knepley /*@ 925a6cbbb48SMatthew G. Knepley PetscDSSetAdjacency - Set the flags for determining variable influence 926a6cbbb48SMatthew G. Knepley 927a6cbbb48SMatthew G. Knepley Not collective 928a6cbbb48SMatthew G. Knepley 929a6cbbb48SMatthew G. Knepley Input Parameters: 930a6cbbb48SMatthew G. Knepley + prob - The PetscDS object 931a6cbbb48SMatthew G. Knepley . f - The field number 932a6cbbb48SMatthew G. Knepley . useCone - Flag for variable influence starting with the cone operation 933a6cbbb48SMatthew G. Knepley - useClosure - Flag for variable influence using transitive closure 934a6cbbb48SMatthew G. Knepley 935a6cbbb48SMatthew G. Knepley Note: See the discussion in DMPlexGetAdjacencyUseCone() and DMPlexGetAdjacencyUseClosure() 936a6cbbb48SMatthew G. Knepley 937a6cbbb48SMatthew G. Knepley Level: developer 938a6cbbb48SMatthew G. Knepley 939a6cbbb48SMatthew G. Knepley .seealso: PetscDSGetAdjacency(), DMPlexGetAdjacencyUseCone(), DMPlexGetAdjacencyUseClosure(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 940a6cbbb48SMatthew G. Knepley @*/ 941a6cbbb48SMatthew G. Knepley PetscErrorCode PetscDSSetAdjacency(PetscDS prob, PetscInt f, PetscBool useCone, PetscBool useClosure) 942a6cbbb48SMatthew G. Knepley { 943a6cbbb48SMatthew G. Knepley PetscFunctionBegin; 944a6cbbb48SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 945a6cbbb48SMatthew 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); 946a6cbbb48SMatthew G. Knepley prob->adjacency[f*2+0] = useCone; 947a6cbbb48SMatthew G. Knepley prob->adjacency[f*2+1] = useClosure; 948a6cbbb48SMatthew G. Knepley PetscFunctionReturn(0); 949a6cbbb48SMatthew G. Knepley } 950a6cbbb48SMatthew G. Knepley 951a6cbbb48SMatthew G. Knepley #undef __FUNCT__ 9522764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetObjective" 9532764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetObjective(PetscDS prob, PetscInt f, 954194d53e6SMatthew G. Knepley void (**obj)(PetscInt dim, PetscInt Nf, 955194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 956194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 957194d53e6SMatthew G. Knepley const PetscReal t, const PetscReal x[], PetscScalar obj[])) 9582764a2aaSMatthew G. Knepley { 9592764a2aaSMatthew G. Knepley PetscFunctionBegin; 9602764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 9612764a2aaSMatthew G. Knepley PetscValidPointer(obj, 2); 9622764a2aaSMatthew G. Knepley if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf); 9632764a2aaSMatthew G. Knepley *obj = prob->obj[f]; 9642764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9652764a2aaSMatthew G. Knepley } 9662764a2aaSMatthew G. Knepley 9672764a2aaSMatthew G. Knepley #undef __FUNCT__ 9682764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetObjective" 9692764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetObjective(PetscDS prob, PetscInt f, 970194d53e6SMatthew G. Knepley void (*obj)(PetscInt dim, PetscInt Nf, 971194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 972194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 973194d53e6SMatthew G. Knepley const PetscReal t, const PetscReal x[], PetscScalar obj[])) 9742764a2aaSMatthew G. Knepley { 9752764a2aaSMatthew G. Knepley PetscErrorCode ierr; 9762764a2aaSMatthew G. Knepley 9772764a2aaSMatthew G. Knepley PetscFunctionBegin; 9782764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 9792764a2aaSMatthew G. Knepley PetscValidFunction(obj, 2); 9802764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 9812764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 9822764a2aaSMatthew G. Knepley prob->obj[f] = obj; 9832764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9842764a2aaSMatthew G. Knepley } 9852764a2aaSMatthew G. Knepley 9862764a2aaSMatthew G. Knepley #undef __FUNCT__ 9872764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetResidual" 988194d53e6SMatthew G. Knepley /*@C 989194d53e6SMatthew G. Knepley PetscDSGetResidual - Get the pointwise residual function for a given test field 990194d53e6SMatthew G. Knepley 991194d53e6SMatthew G. Knepley Not collective 992194d53e6SMatthew G. Knepley 993194d53e6SMatthew G. Knepley Input Parameters: 994194d53e6SMatthew G. Knepley + prob - The PetscDS 995194d53e6SMatthew G. Knepley - f - The test field number 996194d53e6SMatthew G. Knepley 997194d53e6SMatthew G. Knepley Output Parameters: 998194d53e6SMatthew G. Knepley + f0 - integrand for the test function term 999194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 1000194d53e6SMatthew G. Knepley 1001194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1002194d53e6SMatthew G. Knepley 1003194d53e6SMatthew G. Knepley \int_\Omega \phi f_0(u, u_t, \nabla u, x, t) + \nabla\phi \cdot {\vec f}_1(u, u_t, \nabla u, x, t) 1004194d53e6SMatthew G. Knepley 1005194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1006194d53e6SMatthew G. Knepley 1007194d53e6SMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, 1008194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1009194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1010194d53e6SMatthew G. Knepley $ const PetscReal t, const PetscReal x[], PetscScalar f0[]) 1011194d53e6SMatthew G. Knepley 1012194d53e6SMatthew G. Knepley + dim - the spatial dimension 1013194d53e6SMatthew G. Knepley . Nf - the number of fields 1014194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1015194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1016194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1017194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1018194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1019194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1020194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1021194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1022194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1023194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1024194d53e6SMatthew G. Knepley . t - current time 1025194d53e6SMatthew G. Knepley . x - coordinates of the current point 1026194d53e6SMatthew G. Knepley - f0 - output values at the current point 1027194d53e6SMatthew G. Knepley 1028194d53e6SMatthew G. Knepley Level: intermediate 1029194d53e6SMatthew G. Knepley 1030194d53e6SMatthew G. Knepley .seealso: PetscDSSetResidual() 1031194d53e6SMatthew G. Knepley @*/ 10322764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetResidual(PetscDS prob, PetscInt f, 1033194d53e6SMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, 1034194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1035194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1036194d53e6SMatthew G. Knepley const PetscReal t, const PetscReal x[], PetscScalar f0[]), 1037194d53e6SMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, 1038194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1039194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1040194d53e6SMatthew G. Knepley const PetscReal t, const PetscReal x[], PetscScalar f1[])) 10412764a2aaSMatthew G. Knepley { 10422764a2aaSMatthew G. Knepley PetscFunctionBegin; 10432764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 10442764a2aaSMatthew 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); 10452764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 3); *f0 = prob->f[f*2+0];} 10462764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 4); *f1 = prob->f[f*2+1];} 10472764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 10482764a2aaSMatthew G. Knepley } 10492764a2aaSMatthew G. Knepley 10502764a2aaSMatthew G. Knepley #undef __FUNCT__ 10512764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetResidual" 1052194d53e6SMatthew G. Knepley /*@C 1053194d53e6SMatthew G. Knepley PetscDSSetResidual - Set the pointwise residual function for a given test field 1054194d53e6SMatthew G. Knepley 1055194d53e6SMatthew G. Knepley Not collective 1056194d53e6SMatthew G. Knepley 1057194d53e6SMatthew G. Knepley Input Parameters: 1058194d53e6SMatthew G. Knepley + prob - The PetscDS 1059194d53e6SMatthew G. Knepley . f - The test field number 1060194d53e6SMatthew G. Knepley . f0 - integrand for the test function term 1061194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 1062194d53e6SMatthew G. Knepley 1063194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1064194d53e6SMatthew G. Knepley 1065194d53e6SMatthew G. Knepley \int_\Omega \phi f_0(u, u_t, \nabla u, x, t) + \nabla\phi \cdot {\vec f}_1(u, u_t, \nabla u, x, t) 1066194d53e6SMatthew G. Knepley 1067194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1068194d53e6SMatthew G. Knepley 1069194d53e6SMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, 1070194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1071194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1072194d53e6SMatthew G. Knepley $ const PetscReal t, const PetscReal x[], PetscScalar f0[]) 1073194d53e6SMatthew G. Knepley 1074194d53e6SMatthew G. Knepley + dim - the spatial dimension 1075194d53e6SMatthew G. Knepley . Nf - the number of fields 1076194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1077194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1078194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1079194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1080194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1081194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1082194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1083194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1084194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1085194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1086194d53e6SMatthew G. Knepley . t - current time 1087194d53e6SMatthew G. Knepley . x - coordinates of the current point 1088194d53e6SMatthew G. Knepley - f0 - output values at the current point 1089194d53e6SMatthew G. Knepley 1090194d53e6SMatthew G. Knepley Level: intermediate 1091194d53e6SMatthew G. Knepley 1092194d53e6SMatthew G. Knepley .seealso: PetscDSGetResidual() 1093194d53e6SMatthew G. Knepley @*/ 10942764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetResidual(PetscDS prob, PetscInt f, 1095194d53e6SMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, 1096194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1097194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1098194d53e6SMatthew G. Knepley const PetscReal t, const PetscReal x[], PetscScalar f0[]), 1099194d53e6SMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, 1100194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1101194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1102194d53e6SMatthew G. Knepley const PetscReal t, const PetscReal x[], PetscScalar f1[])) 11032764a2aaSMatthew G. Knepley { 11042764a2aaSMatthew G. Knepley PetscErrorCode ierr; 11052764a2aaSMatthew G. Knepley 11062764a2aaSMatthew G. Knepley PetscFunctionBegin; 11072764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 11082764a2aaSMatthew G. Knepley PetscValidFunction(f0, 3); 11092764a2aaSMatthew G. Knepley PetscValidFunction(f1, 4); 11102764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 11112764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 11122764a2aaSMatthew G. Knepley prob->f[f*2+0] = f0; 11132764a2aaSMatthew G. Knepley prob->f[f*2+1] = f1; 11142764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 11152764a2aaSMatthew G. Knepley } 11162764a2aaSMatthew G. Knepley 11172764a2aaSMatthew G. Knepley #undef __FUNCT__ 11182764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetJacobian" 1119194d53e6SMatthew G. Knepley /*@C 1120194d53e6SMatthew G. Knepley PetscDSGetJacobian - Get the pointwise Jacobian function for given test and basis field 1121194d53e6SMatthew G. Knepley 1122194d53e6SMatthew G. Knepley Not collective 1123194d53e6SMatthew G. Knepley 1124194d53e6SMatthew G. Knepley Input Parameters: 1125194d53e6SMatthew G. Knepley + prob - The PetscDS 1126194d53e6SMatthew G. Knepley . f - The test field number 1127194d53e6SMatthew G. Knepley - g - The field number 1128194d53e6SMatthew G. Knepley 1129194d53e6SMatthew G. Knepley Output Parameters: 1130194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 1131194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1132194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1133194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1134194d53e6SMatthew G. Knepley 1135194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1136194d53e6SMatthew G. Knepley 1137194d53e6SMatthew G. Knepley \int_\Omega \phi g_0(u, u_t, \nabla u, x, t) \psi + \phi {\vec g}_1(u, u_t, \nabla u, x, t) \nabla \psi + \nabla\phi \cdot {\vec g}_2(u, u_t, \nabla u, x, t) \psi + \nabla\phi \cdot {\overleftrightarrow g}_3(u, u_t, \nabla u, x, t) \cdot \nabla \psi 1138194d53e6SMatthew G. Knepley 1139194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1140194d53e6SMatthew G. Knepley 1141194d53e6SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, 1142194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1143194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1144194d53e6SMatthew G. Knepley $ const PetscReal t, const PetscReal x[], PetscScalar g0[]) 1145194d53e6SMatthew G. Knepley 1146194d53e6SMatthew G. Knepley + dim - the spatial dimension 1147194d53e6SMatthew G. Knepley . Nf - the number of fields 1148194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1149194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1150194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1151194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1152194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1153194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1154194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1155194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1156194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1157194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1158194d53e6SMatthew G. Knepley . t - current time 1159194d53e6SMatthew G. Knepley . x - coordinates of the current point 1160194d53e6SMatthew G. Knepley - g0 - output values at the current point 1161194d53e6SMatthew G. Knepley 1162194d53e6SMatthew G. Knepley Level: intermediate 1163194d53e6SMatthew G. Knepley 1164194d53e6SMatthew G. Knepley .seealso: PetscDSSetJacobian() 1165194d53e6SMatthew G. Knepley @*/ 11662764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetJacobian(PetscDS prob, PetscInt f, PetscInt g, 1167194d53e6SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, 1168194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1169194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1170194d53e6SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar g0[]), 1171194d53e6SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, 1172194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1173194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1174194d53e6SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar g1[]), 1175194d53e6SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, 1176194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1177194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1178194d53e6SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar g2[]), 1179194d53e6SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, 1180194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1181194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1182194d53e6SMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar g3[])) 11832764a2aaSMatthew G. Knepley { 11842764a2aaSMatthew G. Knepley PetscFunctionBegin; 11852764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 11862764a2aaSMatthew 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); 11872764a2aaSMatthew 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); 11882764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g[(f*prob->Nf + g)*4+0];} 11892764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g[(f*prob->Nf + g)*4+1];} 11902764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g[(f*prob->Nf + g)*4+2];} 11912764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g[(f*prob->Nf + g)*4+3];} 11922764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 11932764a2aaSMatthew G. Knepley } 11942764a2aaSMatthew G. Knepley 11952764a2aaSMatthew G. Knepley #undef __FUNCT__ 11962764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetJacobian" 1197194d53e6SMatthew G. Knepley /*@C 1198194d53e6SMatthew G. Knepley PetscDSSetJacobian - Set the pointwise Jacobian function for given test and basis fields 1199194d53e6SMatthew G. Knepley 1200194d53e6SMatthew G. Knepley Not collective 1201194d53e6SMatthew G. Knepley 1202194d53e6SMatthew G. Knepley Input Parameters: 1203194d53e6SMatthew G. Knepley + prob - The PetscDS 1204194d53e6SMatthew G. Knepley . f - The test field number 1205194d53e6SMatthew G. Knepley . g - The field number 1206194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 1207194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1208194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1209194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1210194d53e6SMatthew G. Knepley 1211194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1212194d53e6SMatthew G. Knepley 1213194d53e6SMatthew G. Knepley \int_\Omega \phi g_0(u, u_t, \nabla u, x, t) \psi + \phi {\vec g}_1(u, u_t, \nabla u, x, t) \nabla \psi + \nabla\phi \cdot {\vec g}_2(u, u_t, \nabla u, x, t) \psi + \nabla\phi \cdot {\overleftrightarrow g}_3(u, u_t, \nabla u, x, t) \cdot \nabla \psi 1214194d53e6SMatthew G. Knepley 1215194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1216194d53e6SMatthew G. Knepley 1217194d53e6SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, 1218194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1219194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1220194d53e6SMatthew G. Knepley $ const PetscReal t, const PetscReal x[], PetscScalar g0[]) 1221194d53e6SMatthew G. Knepley 1222194d53e6SMatthew G. Knepley + dim - the spatial dimension 1223194d53e6SMatthew G. Knepley . Nf - the number of fields 1224194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1225194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1226194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1227194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1228194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1229194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1230194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1231194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1232194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1233194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1234194d53e6SMatthew G. Knepley . t - current time 1235194d53e6SMatthew G. Knepley . x - coordinates of the current point 1236194d53e6SMatthew G. Knepley - g0 - output values at the current point 1237194d53e6SMatthew G. Knepley 1238194d53e6SMatthew G. Knepley Level: intermediate 1239194d53e6SMatthew G. Knepley 1240194d53e6SMatthew G. Knepley .seealso: PetscDSGetJacobian() 1241194d53e6SMatthew G. Knepley @*/ 12422764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetJacobian(PetscDS prob, PetscInt f, PetscInt g, 1243194d53e6SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, 1244194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1245194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1246194d53e6SMatthew G. Knepley const PetscReal t, const PetscReal x[], PetscScalar g0[]), 1247194d53e6SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, 1248194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1249194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1250194d53e6SMatthew G. Knepley const PetscReal t, const PetscReal x[], PetscScalar g1[]), 1251194d53e6SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, 1252194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1253194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1254194d53e6SMatthew G. Knepley const PetscReal t, const PetscReal x[], PetscScalar g2[]), 1255194d53e6SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, 1256194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1257194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1258194d53e6SMatthew G. Knepley const PetscReal t, const PetscReal x[], PetscScalar g3[])) 12592764a2aaSMatthew G. Knepley { 12602764a2aaSMatthew G. Knepley PetscErrorCode ierr; 12612764a2aaSMatthew G. Knepley 12622764a2aaSMatthew G. Knepley PetscFunctionBegin; 12632764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 12642764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 12652764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 12662764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 12672764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 12682764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 12692764a2aaSMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 12702764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 12712764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+0] = g0; 12722764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+1] = g1; 12732764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+2] = g2; 12742764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+3] = g3; 12752764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 12762764a2aaSMatthew G. Knepley } 12772764a2aaSMatthew G. Knepley 12782764a2aaSMatthew G. Knepley #undef __FUNCT__ 12790c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSGetRiemannSolver" 12800c2f2876SMatthew G. Knepley /*@C 12810c2f2876SMatthew G. Knepley PetscDSGetRiemannSolver - Returns the Riemann solver for the given field 12820c2f2876SMatthew G. Knepley 12830c2f2876SMatthew G. Knepley Not collective 12840c2f2876SMatthew G. Knepley 12850c2f2876SMatthew G. Knepley Input Arguments: 12860c2f2876SMatthew G. Knepley + prob - The PetscDS object 12870c2f2876SMatthew G. Knepley - f - The field number 12880c2f2876SMatthew G. Knepley 12890c2f2876SMatthew G. Knepley Output Argument: 12900c2f2876SMatthew G. Knepley . r - Riemann solver 12910c2f2876SMatthew G. Knepley 12920c2f2876SMatthew G. Knepley Calling sequence for r: 12930c2f2876SMatthew G. Knepley 1294*5db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 12950c2f2876SMatthew G. Knepley 1296*5db36cf9SMatthew G. Knepley + dim - The spatial dimension 1297*5db36cf9SMatthew G. Knepley . Nf - The number of fields 1298*5db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 12990c2f2876SMatthew G. Knepley . n - The normal vector to the interface 13000c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 13010c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 13020c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 13030c2f2876SMatthew G. Knepley - ctx - optional user context 13040c2f2876SMatthew G. Knepley 13050c2f2876SMatthew G. Knepley Level: intermediate 13060c2f2876SMatthew G. Knepley 13070c2f2876SMatthew G. Knepley .seealso: PetscDSSetRiemannSolver() 13080c2f2876SMatthew G. Knepley @*/ 13090c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetRiemannSolver(PetscDS prob, PetscInt f, 1310*5db36cf9SMatthew G. Knepley void (**r)(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx)) 13110c2f2876SMatthew G. Knepley { 13120c2f2876SMatthew G. Knepley PetscFunctionBegin; 13130c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 13140c2f2876SMatthew 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); 13150c2f2876SMatthew G. Knepley PetscValidPointer(r, 3); 13160c2f2876SMatthew G. Knepley *r = prob->r[f]; 13170c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 13180c2f2876SMatthew G. Knepley } 13190c2f2876SMatthew G. Knepley 13200c2f2876SMatthew G. Knepley #undef __FUNCT__ 13210c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSSetRiemannSolver" 13220c2f2876SMatthew G. Knepley /*@C 13230c2f2876SMatthew G. Knepley PetscDSSetRiemannSolver - Sets the Riemann solver for the given field 13240c2f2876SMatthew G. Knepley 13250c2f2876SMatthew G. Knepley Not collective 13260c2f2876SMatthew G. Knepley 13270c2f2876SMatthew G. Knepley Input Arguments: 13280c2f2876SMatthew G. Knepley + prob - The PetscDS object 13290c2f2876SMatthew G. Knepley . f - The field number 13300c2f2876SMatthew G. Knepley - r - Riemann solver 13310c2f2876SMatthew G. Knepley 13320c2f2876SMatthew G. Knepley Calling sequence for r: 13330c2f2876SMatthew G. Knepley 1334*5db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 13350c2f2876SMatthew G. Knepley 1336*5db36cf9SMatthew G. Knepley + dim - The spatial dimension 1337*5db36cf9SMatthew G. Knepley . Nf - The number of fields 1338*5db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 13390c2f2876SMatthew G. Knepley . n - The normal vector to the interface 13400c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 13410c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 13420c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 13430c2f2876SMatthew G. Knepley - ctx - optional user context 13440c2f2876SMatthew G. Knepley 13450c2f2876SMatthew G. Knepley Level: intermediate 13460c2f2876SMatthew G. Knepley 13470c2f2876SMatthew G. Knepley .seealso: PetscDSGetRiemannSolver() 13480c2f2876SMatthew G. Knepley @*/ 13490c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetRiemannSolver(PetscDS prob, PetscInt f, 1350*5db36cf9SMatthew G. Knepley void (*r)(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx)) 13510c2f2876SMatthew G. Knepley { 13520c2f2876SMatthew G. Knepley PetscErrorCode ierr; 13530c2f2876SMatthew G. Knepley 13540c2f2876SMatthew G. Knepley PetscFunctionBegin; 13550c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 13560c2f2876SMatthew G. Knepley PetscValidFunction(r, 3); 13570c2f2876SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 13580c2f2876SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 13590c2f2876SMatthew G. Knepley prob->r[f] = r; 13600c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 13610c2f2876SMatthew G. Knepley } 13620c2f2876SMatthew G. Knepley 13630c2f2876SMatthew G. Knepley #undef __FUNCT__ 13640c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSGetContext" 13650c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetContext(PetscDS prob, PetscInt f, void **ctx) 13660c2f2876SMatthew G. Knepley { 13670c2f2876SMatthew G. Knepley PetscFunctionBegin; 13680c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 13690c2f2876SMatthew 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); 13700c2f2876SMatthew G. Knepley PetscValidPointer(ctx, 3); 13710c2f2876SMatthew G. Knepley *ctx = prob->ctx[f]; 13720c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 13730c2f2876SMatthew G. Knepley } 13740c2f2876SMatthew G. Knepley 13750c2f2876SMatthew G. Knepley #undef __FUNCT__ 13760c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSSetContext" 13770c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetContext(PetscDS prob, PetscInt f, void *ctx) 13780c2f2876SMatthew G. Knepley { 13790c2f2876SMatthew G. Knepley PetscErrorCode ierr; 13800c2f2876SMatthew G. Knepley 13810c2f2876SMatthew G. Knepley PetscFunctionBegin; 13820c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 13830c2f2876SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 13840c2f2876SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 13850c2f2876SMatthew G. Knepley prob->ctx[f] = ctx; 13860c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 13870c2f2876SMatthew G. Knepley } 13880c2f2876SMatthew G. Knepley 13890c2f2876SMatthew G. Knepley #undef __FUNCT__ 13902764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdResidual" 1391194d53e6SMatthew G. Knepley /*@C 1392194d53e6SMatthew G. Knepley PetscDSGetBdResidual - Get the pointwise boundary residual function for a given test field 1393194d53e6SMatthew G. Knepley 1394194d53e6SMatthew G. Knepley Not collective 1395194d53e6SMatthew G. Knepley 1396194d53e6SMatthew G. Knepley Input Parameters: 1397194d53e6SMatthew G. Knepley + prob - The PetscDS 1398194d53e6SMatthew G. Knepley - f - The test field number 1399194d53e6SMatthew G. Knepley 1400194d53e6SMatthew G. Knepley Output Parameters: 1401194d53e6SMatthew G. Knepley + f0 - boundary integrand for the test function term 1402194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 1403194d53e6SMatthew G. Knepley 1404194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1405194d53e6SMatthew G. Knepley 1406194d53e6SMatthew G. Knepley \int_\Gamma \phi {\vec f}_0(u, u_t, \nabla u, x, t) \cdot \hat n + \nabla\phi \cdot {\overleftrightarrow f}_1(u, u_t, \nabla u, x, t) \cdot \hat n 1407194d53e6SMatthew G. Knepley 1408194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1409194d53e6SMatthew G. Knepley 1410194d53e6SMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, 1411194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1412194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1413194d53e6SMatthew G. Knepley $ const PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 1414194d53e6SMatthew G. Knepley 1415194d53e6SMatthew G. Knepley + dim - the spatial dimension 1416194d53e6SMatthew G. Knepley . Nf - the number of fields 1417194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1418194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1419194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1420194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1421194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1422194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1423194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1424194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1425194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1426194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1427194d53e6SMatthew G. Knepley . t - current time 1428194d53e6SMatthew G. Knepley . x - coordinates of the current point 1429194d53e6SMatthew G. Knepley . n - unit normal at the current point 1430194d53e6SMatthew G. Knepley - f0 - output values at the current point 1431194d53e6SMatthew G. Knepley 1432194d53e6SMatthew G. Knepley Level: intermediate 1433194d53e6SMatthew G. Knepley 1434194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdResidual() 1435194d53e6SMatthew G. Knepley @*/ 14362764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdResidual(PetscDS prob, PetscInt f, 1437194d53e6SMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, 1438194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1439194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1440194d53e6SMatthew G. Knepley const PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]), 1441194d53e6SMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, 1442194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1443194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1444194d53e6SMatthew G. Knepley const PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f1[])) 14452764a2aaSMatthew G. Knepley { 14462764a2aaSMatthew G. Knepley PetscFunctionBegin; 14472764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 14482764a2aaSMatthew 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); 14492764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 3); *f0 = prob->fBd[f*2+0];} 14502764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 4); *f1 = prob->fBd[f*2+1];} 14512764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 14522764a2aaSMatthew G. Knepley } 14532764a2aaSMatthew G. Knepley 14542764a2aaSMatthew G. Knepley #undef __FUNCT__ 14552764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdResidual" 1456194d53e6SMatthew G. Knepley /*@C 1457194d53e6SMatthew G. Knepley PetscDSSetBdResidual - Get the pointwise boundary residual function for a given test field 1458194d53e6SMatthew G. Knepley 1459194d53e6SMatthew G. Knepley Not collective 1460194d53e6SMatthew G. Knepley 1461194d53e6SMatthew G. Knepley Input Parameters: 1462194d53e6SMatthew G. Knepley + prob - The PetscDS 1463194d53e6SMatthew G. Knepley . f - The test field number 1464194d53e6SMatthew G. Knepley . f0 - boundary integrand for the test function term 1465194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 1466194d53e6SMatthew G. Knepley 1467194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1468194d53e6SMatthew G. Knepley 1469194d53e6SMatthew G. Knepley \int_\Gamma \phi {\vec f}_0(u, u_t, \nabla u, x, t) \cdot \hat n + \nabla\phi \cdot {\overleftrightarrow f}_1(u, u_t, \nabla u, x, t) \cdot \hat n 1470194d53e6SMatthew G. Knepley 1471194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1472194d53e6SMatthew G. Knepley 1473194d53e6SMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, 1474194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1475194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1476194d53e6SMatthew G. Knepley $ const PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 1477194d53e6SMatthew G. Knepley 1478194d53e6SMatthew G. Knepley + dim - the spatial dimension 1479194d53e6SMatthew G. Knepley . Nf - the number of fields 1480194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1481194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1482194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1483194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1484194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1485194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1486194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1487194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1488194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1489194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1490194d53e6SMatthew G. Knepley . t - current time 1491194d53e6SMatthew G. Knepley . x - coordinates of the current point 1492194d53e6SMatthew G. Knepley . n - unit normal at the current point 1493194d53e6SMatthew G. Knepley - f0 - output values at the current point 1494194d53e6SMatthew G. Knepley 1495194d53e6SMatthew G. Knepley Level: intermediate 1496194d53e6SMatthew G. Knepley 1497194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdResidual() 1498194d53e6SMatthew G. Knepley @*/ 14992764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdResidual(PetscDS prob, PetscInt f, 1500194d53e6SMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, 1501194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1502194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1503194d53e6SMatthew G. Knepley const PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]), 1504194d53e6SMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, 1505194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1506194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1507194d53e6SMatthew G. Knepley const PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f1[])) 15082764a2aaSMatthew G. Knepley { 15092764a2aaSMatthew G. Knepley PetscErrorCode ierr; 15102764a2aaSMatthew G. Knepley 15112764a2aaSMatthew G. Knepley PetscFunctionBegin; 15122764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 15132764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 15142764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 15152764a2aaSMatthew G. Knepley if (f0) {PetscValidFunction(f0, 3); prob->fBd[f*2+0] = f0;} 15162764a2aaSMatthew G. Knepley if (f1) {PetscValidFunction(f1, 4); prob->fBd[f*2+1] = f1;} 15172764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 15182764a2aaSMatthew G. Knepley } 15192764a2aaSMatthew G. Knepley 15202764a2aaSMatthew G. Knepley #undef __FUNCT__ 15212764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdJacobian" 1522194d53e6SMatthew G. Knepley /*@C 1523194d53e6SMatthew G. Knepley PetscDSGetBdJacobian - Get the pointwise boundary Jacobian function for given test and basis field 1524194d53e6SMatthew G. Knepley 1525194d53e6SMatthew G. Knepley Not collective 1526194d53e6SMatthew G. Knepley 1527194d53e6SMatthew G. Knepley Input Parameters: 1528194d53e6SMatthew G. Knepley + prob - The PetscDS 1529194d53e6SMatthew G. Knepley . f - The test field number 1530194d53e6SMatthew G. Knepley - g - The field number 1531194d53e6SMatthew G. Knepley 1532194d53e6SMatthew G. Knepley Output Parameters: 1533194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 1534194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1535194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1536194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1537194d53e6SMatthew G. Knepley 1538194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1539194d53e6SMatthew G. Knepley 1540194d53e6SMatthew G. Knepley \int_\Gamma \phi {\vec g}_0(u, u_t, \nabla u, x, t) \cdot \hat n \psi + \phi {\vec g}_1(u, u_t, \nabla u, x, t) \cdot \hat n \nabla \psi + \nabla\phi \cdot {\vec g}_2(u, u_t, \nabla u, x, t) \cdot \hat n \psi + \nabla\phi \cdot {\overleftrightarrow g}_3(u, u_t, \nabla u, x, t) \cdot \hat n \cdot \nabla \psi 1541194d53e6SMatthew G. Knepley 1542194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1543194d53e6SMatthew G. Knepley 1544194d53e6SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, 1545194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1546194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1547194d53e6SMatthew G. Knepley $ const PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 1548194d53e6SMatthew G. Knepley 1549194d53e6SMatthew G. Knepley + dim - the spatial dimension 1550194d53e6SMatthew G. Knepley . Nf - the number of fields 1551194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1552194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1553194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1554194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1555194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1556194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1557194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1558194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1559194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1560194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1561194d53e6SMatthew G. Knepley . t - current time 1562194d53e6SMatthew G. Knepley . x - coordinates of the current point 1563194d53e6SMatthew G. Knepley . n - normal at the current point 1564194d53e6SMatthew G. Knepley - g0 - output values at the current point 1565194d53e6SMatthew G. Knepley 1566194d53e6SMatthew G. Knepley Level: intermediate 1567194d53e6SMatthew G. Knepley 1568194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdJacobian() 1569194d53e6SMatthew G. Knepley @*/ 15702764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdJacobian(PetscDS prob, PetscInt f, PetscInt g, 1571194d53e6SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, 1572194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1573194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1574194d53e6SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]), 1575194d53e6SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, 1576194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1577194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1578194d53e6SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g1[]), 1579194d53e6SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, 1580194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1581194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1582194d53e6SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g2[]), 1583194d53e6SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, 1584194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1585194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1586194d53e6SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g3[])) 15872764a2aaSMatthew G. Knepley { 15882764a2aaSMatthew G. Knepley PetscFunctionBegin; 15892764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 15902764a2aaSMatthew 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); 15912764a2aaSMatthew 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); 15922764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gBd[(f*prob->Nf + g)*4+0];} 15932764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gBd[(f*prob->Nf + g)*4+1];} 15942764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gBd[(f*prob->Nf + g)*4+2];} 15952764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gBd[(f*prob->Nf + g)*4+3];} 15962764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 15972764a2aaSMatthew G. Knepley } 15982764a2aaSMatthew G. Knepley 15992764a2aaSMatthew G. Knepley #undef __FUNCT__ 16002764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdJacobian" 1601194d53e6SMatthew G. Knepley /*@C 1602194d53e6SMatthew G. Knepley PetscDSSetBdJacobian - Set the pointwise boundary Jacobian function for given test and basis field 1603194d53e6SMatthew G. Knepley 1604194d53e6SMatthew G. Knepley Not collective 1605194d53e6SMatthew G. Knepley 1606194d53e6SMatthew G. Knepley Input Parameters: 1607194d53e6SMatthew G. Knepley + prob - The PetscDS 1608194d53e6SMatthew G. Knepley . f - The test field number 1609194d53e6SMatthew G. Knepley . g - The field number 1610194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 1611194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1612194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1613194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1614194d53e6SMatthew G. Knepley 1615194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1616194d53e6SMatthew G. Knepley 1617194d53e6SMatthew G. Knepley \int_\Gamma \phi {\vec g}_0(u, u_t, \nabla u, x, t) \cdot \hat n \psi + \phi {\vec g}_1(u, u_t, \nabla u, x, t) \cdot \hat n \nabla \psi + \nabla\phi \cdot {\vec g}_2(u, u_t, \nabla u, x, t) \cdot \hat n \psi + \nabla\phi \cdot {\overleftrightarrow g}_3(u, u_t, \nabla u, x, t) \cdot \hat n \cdot \nabla \psi 1618194d53e6SMatthew G. Knepley 1619194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1620194d53e6SMatthew G. Knepley 1621194d53e6SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, 1622194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1623194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1624194d53e6SMatthew G. Knepley $ const PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 1625194d53e6SMatthew G. Knepley 1626194d53e6SMatthew G. Knepley + dim - the spatial dimension 1627194d53e6SMatthew G. Knepley . Nf - the number of fields 1628194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1629194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1630194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1631194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1632194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1633194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1634194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1635194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1636194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1637194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1638194d53e6SMatthew G. Knepley . t - current time 1639194d53e6SMatthew G. Knepley . x - coordinates of the current point 1640194d53e6SMatthew G. Knepley . n - normal at the current point 1641194d53e6SMatthew G. Knepley - g0 - output values at the current point 1642194d53e6SMatthew G. Knepley 1643194d53e6SMatthew G. Knepley Level: intermediate 1644194d53e6SMatthew G. Knepley 1645194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdJacobian() 1646194d53e6SMatthew G. Knepley @*/ 16472764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdJacobian(PetscDS prob, PetscInt f, PetscInt g, 1648194d53e6SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, 1649194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1650194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1651194d53e6SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]), 1652194d53e6SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, 1653194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1654194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1655194d53e6SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g1[]), 1656194d53e6SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, 1657194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1658194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1659194d53e6SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g2[]), 1660194d53e6SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, 1661194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1662194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1663194d53e6SMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g3[])) 16642764a2aaSMatthew G. Knepley { 16652764a2aaSMatthew G. Knepley PetscErrorCode ierr; 16662764a2aaSMatthew G. Knepley 16672764a2aaSMatthew G. Knepley PetscFunctionBegin; 16682764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 16692764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 16702764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 16712764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 16722764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 16732764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 16742764a2aaSMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 16752764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 16762764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+0] = g0; 16772764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+1] = g1; 16782764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+2] = g2; 16792764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+3] = g3; 16802764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 16812764a2aaSMatthew G. Knepley } 16822764a2aaSMatthew G. Knepley 16832764a2aaSMatthew G. Knepley #undef __FUNCT__ 16842764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetFieldOffset" 1685bc4ae4beSMatthew G. Knepley /*@ 1686bc4ae4beSMatthew G. Knepley PetscDSGetFieldOffset - Returns the offset of the given field in the full space basis 1687bc4ae4beSMatthew G. Knepley 1688bc4ae4beSMatthew G. Knepley Not collective 1689bc4ae4beSMatthew G. Knepley 1690bc4ae4beSMatthew G. Knepley Input Parameters: 1691bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 1692bc4ae4beSMatthew G. Knepley - f - The field number 1693bc4ae4beSMatthew G. Knepley 1694bc4ae4beSMatthew G. Knepley Output Parameter: 1695bc4ae4beSMatthew G. Knepley . off - The offset 1696bc4ae4beSMatthew G. Knepley 1697bc4ae4beSMatthew G. Knepley Level: beginner 1698bc4ae4beSMatthew G. Knepley 1699bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 1700bc4ae4beSMatthew G. Knepley @*/ 17012764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetFieldOffset(PetscDS prob, PetscInt f, PetscInt *off) 17022764a2aaSMatthew G. Knepley { 17032764a2aaSMatthew G. Knepley PetscInt g; 17042764a2aaSMatthew G. Knepley PetscErrorCode ierr; 17052764a2aaSMatthew G. Knepley 17062764a2aaSMatthew G. Knepley PetscFunctionBegin; 17072764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 17082764a2aaSMatthew G. Knepley PetscValidPointer(off, 3); 17092764a2aaSMatthew 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); 17102764a2aaSMatthew G. Knepley *off = 0; 17112764a2aaSMatthew G. Knepley for (g = 0; g < f; ++g) { 17122764a2aaSMatthew G. Knepley PetscFE fe = (PetscFE) prob->disc[g]; 17132764a2aaSMatthew G. Knepley PetscInt Nb, Nc; 17142764a2aaSMatthew G. Knepley 17152764a2aaSMatthew G. Knepley ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr); 17162764a2aaSMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 17172764a2aaSMatthew G. Knepley *off += Nb*Nc; 17182764a2aaSMatthew G. Knepley } 17192764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 17202764a2aaSMatthew G. Knepley } 17212764a2aaSMatthew G. Knepley 17222764a2aaSMatthew G. Knepley #undef __FUNCT__ 17232764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdFieldOffset" 1724bc4ae4beSMatthew G. Knepley /*@ 1725c3ac4435SMatthew G. Knepley PetscDSGetBdFieldOffset - Returns the offset of the given field in the full space boundary basis 1726bc4ae4beSMatthew G. Knepley 1727bc4ae4beSMatthew G. Knepley Not collective 1728bc4ae4beSMatthew G. Knepley 1729bc4ae4beSMatthew G. Knepley Input Parameters: 1730bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 1731bc4ae4beSMatthew G. Knepley - f - The field number 1732bc4ae4beSMatthew G. Knepley 1733bc4ae4beSMatthew G. Knepley Output Parameter: 1734bc4ae4beSMatthew G. Knepley . off - The boundary offset 1735bc4ae4beSMatthew G. Knepley 1736bc4ae4beSMatthew G. Knepley Level: beginner 1737bc4ae4beSMatthew G. Knepley 1738bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 1739bc4ae4beSMatthew G. Knepley @*/ 17402764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdFieldOffset(PetscDS prob, PetscInt f, PetscInt *off) 17412764a2aaSMatthew G. Knepley { 17422764a2aaSMatthew G. Knepley PetscInt g; 17432764a2aaSMatthew G. Knepley PetscErrorCode ierr; 17442764a2aaSMatthew G. Knepley 17452764a2aaSMatthew G. Knepley PetscFunctionBegin; 17462764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 17472764a2aaSMatthew G. Knepley PetscValidPointer(off, 3); 17482764a2aaSMatthew 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); 17492764a2aaSMatthew G. Knepley *off = 0; 17502764a2aaSMatthew G. Knepley for (g = 0; g < f; ++g) { 17512764a2aaSMatthew G. Knepley PetscFE fe = (PetscFE) prob->discBd[g]; 17522764a2aaSMatthew G. Knepley PetscInt Nb, Nc; 17532764a2aaSMatthew G. Knepley 17542764a2aaSMatthew G. Knepley ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr); 17552764a2aaSMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 17562764a2aaSMatthew G. Knepley *off += Nb*Nc; 17576ce16762SMatthew G. Knepley } 17586ce16762SMatthew G. Knepley PetscFunctionReturn(0); 17596ce16762SMatthew G. Knepley } 17606ce16762SMatthew G. Knepley 17616ce16762SMatthew G. Knepley #undef __FUNCT__ 17626ce16762SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentOffset" 17636ce16762SMatthew G. Knepley /*@ 17646ce16762SMatthew G. Knepley PetscDSGetComponentOffset - Returns the offset of the given field on an evaluation point 17656ce16762SMatthew G. Knepley 17666ce16762SMatthew G. Knepley Not collective 17676ce16762SMatthew G. Knepley 17686ce16762SMatthew G. Knepley Input Parameters: 17696ce16762SMatthew G. Knepley + prob - The PetscDS object 17706ce16762SMatthew G. Knepley - f - The field number 17716ce16762SMatthew G. Knepley 17726ce16762SMatthew G. Knepley Output Parameter: 17736ce16762SMatthew G. Knepley . off - The offset 17746ce16762SMatthew G. Knepley 17756ce16762SMatthew G. Knepley Level: beginner 17766ce16762SMatthew G. Knepley 17776ce16762SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 17786ce16762SMatthew G. Knepley @*/ 17796ce16762SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffset(PetscDS prob, PetscInt f, PetscInt *off) 17806ce16762SMatthew G. Knepley { 17816ce16762SMatthew G. Knepley PetscInt g; 17826ce16762SMatthew G. Knepley PetscErrorCode ierr; 17836ce16762SMatthew G. Knepley 17846ce16762SMatthew G. Knepley PetscFunctionBegin; 17856ce16762SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 17866ce16762SMatthew G. Knepley PetscValidPointer(off, 3); 17876ce16762SMatthew 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); 17886ce16762SMatthew G. Knepley *off = 0; 17896ce16762SMatthew G. Knepley for (g = 0; g < f; ++g) { 17906ce16762SMatthew G. Knepley PetscFE fe = (PetscFE) prob->disc[g]; 17916ce16762SMatthew G. Knepley PetscInt Nc; 17926ce16762SMatthew G. Knepley 17936ce16762SMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 17946ce16762SMatthew G. Knepley *off += Nc; 17952764a2aaSMatthew G. Knepley } 17962764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 17972764a2aaSMatthew G. Knepley } 17982764a2aaSMatthew G. Knepley 17992764a2aaSMatthew G. Knepley #undef __FUNCT__ 1800194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentOffsets" 1801194d53e6SMatthew G. Knepley /*@ 1802194d53e6SMatthew G. Knepley PetscDSGetComponentOffsets - Returns the offset of each field on an evaluation point 1803194d53e6SMatthew G. Knepley 1804194d53e6SMatthew G. Knepley Not collective 1805194d53e6SMatthew G. Knepley 1806194d53e6SMatthew G. Knepley Input Parameter: 1807194d53e6SMatthew G. Knepley . prob - The PetscDS object 1808194d53e6SMatthew G. Knepley 1809194d53e6SMatthew G. Knepley Output Parameter: 1810194d53e6SMatthew G. Knepley . offsets - The offsets 1811194d53e6SMatthew G. Knepley 1812194d53e6SMatthew G. Knepley Level: beginner 1813194d53e6SMatthew G. Knepley 1814194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 1815194d53e6SMatthew G. Knepley @*/ 1816194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffsets(PetscDS prob, PetscInt *offsets[]) 1817194d53e6SMatthew G. Knepley { 1818194d53e6SMatthew G. Knepley PetscInt g; 1819194d53e6SMatthew G. Knepley PetscErrorCode ierr; 1820194d53e6SMatthew G. Knepley 1821194d53e6SMatthew G. Knepley PetscFunctionBegin; 1822194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1823194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 1824194d53e6SMatthew G. Knepley *offsets = prob->off; 1825194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 1826194d53e6SMatthew G. Knepley } 1827194d53e6SMatthew G. Knepley 1828194d53e6SMatthew G. Knepley #undef __FUNCT__ 1829194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentDerivativeOffsets" 1830194d53e6SMatthew G. Knepley /*@ 1831194d53e6SMatthew G. Knepley PetscDSGetComponentDerivativeOffsets - Returns the offset of each field derivative on an evaluation point 1832194d53e6SMatthew G. Knepley 1833194d53e6SMatthew G. Knepley Not collective 1834194d53e6SMatthew G. Knepley 1835194d53e6SMatthew G. Knepley Input Parameter: 1836194d53e6SMatthew G. Knepley . prob - The PetscDS object 1837194d53e6SMatthew G. Knepley 1838194d53e6SMatthew G. Knepley Output Parameter: 1839194d53e6SMatthew G. Knepley . offsets - The offsets 1840194d53e6SMatthew G. Knepley 1841194d53e6SMatthew G. Knepley Level: beginner 1842194d53e6SMatthew G. Knepley 1843194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 1844194d53e6SMatthew G. Knepley @*/ 1845194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentDerivativeOffsets(PetscDS prob, PetscInt *offsets[]) 1846194d53e6SMatthew G. Knepley { 1847194d53e6SMatthew G. Knepley PetscInt g; 1848194d53e6SMatthew G. Knepley PetscErrorCode ierr; 1849194d53e6SMatthew G. Knepley 1850194d53e6SMatthew G. Knepley PetscFunctionBegin; 1851194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1852194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 1853194d53e6SMatthew G. Knepley *offsets = prob->offDer; 1854194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 1855194d53e6SMatthew G. Knepley } 1856194d53e6SMatthew G. Knepley 1857194d53e6SMatthew G. Knepley #undef __FUNCT__ 1858194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentBdOffsets" 1859194d53e6SMatthew G. Knepley /*@ 1860194d53e6SMatthew G. Knepley PetscDSGetComponentBdOffsets - Returns the offset of each field on a boundary evaluation point 1861194d53e6SMatthew G. Knepley 1862194d53e6SMatthew G. Knepley Not collective 1863194d53e6SMatthew G. Knepley 1864194d53e6SMatthew G. Knepley Input Parameter: 1865194d53e6SMatthew G. Knepley . prob - The PetscDS object 1866194d53e6SMatthew G. Knepley 1867194d53e6SMatthew G. Knepley Output Parameter: 1868194d53e6SMatthew G. Knepley . offsets - The offsets 1869194d53e6SMatthew G. Knepley 1870194d53e6SMatthew G. Knepley Level: beginner 1871194d53e6SMatthew G. Knepley 1872194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 1873194d53e6SMatthew G. Knepley @*/ 1874194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentBdOffsets(PetscDS prob, PetscInt *offsets[]) 1875194d53e6SMatthew G. Knepley { 1876194d53e6SMatthew G. Knepley PetscInt g; 1877194d53e6SMatthew G. Knepley PetscErrorCode ierr; 1878194d53e6SMatthew G. Knepley 1879194d53e6SMatthew G. Knepley PetscFunctionBegin; 1880194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1881194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 1882194d53e6SMatthew G. Knepley *offsets = prob->offBd; 1883194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 1884194d53e6SMatthew G. Knepley } 1885194d53e6SMatthew G. Knepley 1886194d53e6SMatthew G. Knepley #undef __FUNCT__ 1887194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentBdDerivativeOffsets" 1888194d53e6SMatthew G. Knepley /*@ 1889194d53e6SMatthew G. Knepley PetscDSGetComponentBdDerivativeOffsets - Returns the offset of each field derivative on a boundary evaluation point 1890194d53e6SMatthew G. Knepley 1891194d53e6SMatthew G. Knepley Not collective 1892194d53e6SMatthew G. Knepley 1893194d53e6SMatthew G. Knepley Input Parameter: 1894194d53e6SMatthew G. Knepley . prob - The PetscDS object 1895194d53e6SMatthew G. Knepley 1896194d53e6SMatthew G. Knepley Output Parameter: 1897194d53e6SMatthew G. Knepley . offsets - The offsets 1898194d53e6SMatthew G. Knepley 1899194d53e6SMatthew G. Knepley Level: beginner 1900194d53e6SMatthew G. Knepley 1901194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 1902194d53e6SMatthew G. Knepley @*/ 1903194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentBdDerivativeOffsets(PetscDS prob, PetscInt *offsets[]) 1904194d53e6SMatthew G. Knepley { 1905194d53e6SMatthew G. Knepley PetscInt g; 1906194d53e6SMatthew G. Knepley PetscErrorCode ierr; 1907194d53e6SMatthew G. Knepley 1908194d53e6SMatthew G. Knepley PetscFunctionBegin; 1909194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1910194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 1911194d53e6SMatthew G. Knepley *offsets = prob->offDerBd; 1912194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 1913194d53e6SMatthew G. Knepley } 1914194d53e6SMatthew G. Knepley 1915194d53e6SMatthew G. Knepley #undef __FUNCT__ 19162764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTabulation" 191768c9edb9SMatthew G. Knepley /*@C 191868c9edb9SMatthew G. Knepley PetscDSGetTabulation - Return the basis tabulation at quadrature points for the volume discretization 191968c9edb9SMatthew G. Knepley 192068c9edb9SMatthew G. Knepley Not collective 192168c9edb9SMatthew G. Knepley 192268c9edb9SMatthew G. Knepley Input Parameter: 192368c9edb9SMatthew G. Knepley . prob - The PetscDS object 192468c9edb9SMatthew G. Knepley 192568c9edb9SMatthew G. Knepley Output Parameters: 192668c9edb9SMatthew G. Knepley + basis - The basis function tabulation at quadrature points 192768c9edb9SMatthew G. Knepley - basisDer - The basis function derivative tabulation at quadrature points 192868c9edb9SMatthew G. Knepley 192968c9edb9SMatthew G. Knepley Level: intermediate 193068c9edb9SMatthew G. Knepley 193168c9edb9SMatthew G. Knepley .seealso: PetscDSGetBdTabulation(), PetscDSCreate() 193268c9edb9SMatthew G. Knepley @*/ 19332764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTabulation(PetscDS prob, PetscReal ***basis, PetscReal ***basisDer) 19342764a2aaSMatthew G. Knepley { 19352764a2aaSMatthew G. Knepley PetscErrorCode ierr; 19362764a2aaSMatthew G. Knepley 19372764a2aaSMatthew G. Knepley PetscFunctionBegin; 19382764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 19392764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 19402764a2aaSMatthew G. Knepley if (basis) {PetscValidPointer(basis, 2); *basis = prob->basis;} 19412764a2aaSMatthew G. Knepley if (basisDer) {PetscValidPointer(basisDer, 3); *basisDer = prob->basisDer;} 19422764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 19432764a2aaSMatthew G. Knepley } 19442764a2aaSMatthew G. Knepley 19452764a2aaSMatthew G. Knepley #undef __FUNCT__ 19462764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdTabulation" 194768c9edb9SMatthew G. Knepley /*@C 194868c9edb9SMatthew G. Knepley PetscDSGetBdTabulation - Return the basis tabulation at quadrature points for the boundary discretization 194968c9edb9SMatthew G. Knepley 195068c9edb9SMatthew G. Knepley Not collective 195168c9edb9SMatthew G. Knepley 195268c9edb9SMatthew G. Knepley Input Parameter: 195368c9edb9SMatthew G. Knepley . prob - The PetscDS object 195468c9edb9SMatthew G. Knepley 195568c9edb9SMatthew G. Knepley Output Parameters: 195668c9edb9SMatthew G. Knepley + basis - The basis function tabulation at quadrature points 195768c9edb9SMatthew G. Knepley - basisDer - The basis function derivative tabulation at quadrature points 195868c9edb9SMatthew G. Knepley 195968c9edb9SMatthew G. Knepley Level: intermediate 196068c9edb9SMatthew G. Knepley 196168c9edb9SMatthew G. Knepley .seealso: PetscDSGetTabulation(), PetscDSCreate() 196268c9edb9SMatthew G. Knepley @*/ 19632764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdTabulation(PetscDS prob, PetscReal ***basis, PetscReal ***basisDer) 19642764a2aaSMatthew G. Knepley { 19652764a2aaSMatthew G. Knepley PetscErrorCode ierr; 19662764a2aaSMatthew G. Knepley 19672764a2aaSMatthew G. Knepley PetscFunctionBegin; 19682764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 19692764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 19702764a2aaSMatthew G. Knepley if (basis) {PetscValidPointer(basis, 2); *basis = prob->basisBd;} 19712764a2aaSMatthew G. Knepley if (basisDer) {PetscValidPointer(basisDer, 3); *basisDer = prob->basisDerBd;} 19722764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 19732764a2aaSMatthew G. Knepley } 19742764a2aaSMatthew G. Knepley 19752764a2aaSMatthew G. Knepley #undef __FUNCT__ 19762764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetEvaluationArrays" 19772764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetEvaluationArrays(PetscDS prob, PetscScalar **u, PetscScalar **u_t, PetscScalar **u_x) 19782764a2aaSMatthew G. Knepley { 19792764a2aaSMatthew G. Knepley PetscErrorCode ierr; 19802764a2aaSMatthew G. Knepley 19812764a2aaSMatthew G. Knepley PetscFunctionBegin; 19822764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 19832764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 19842764a2aaSMatthew G. Knepley if (u) {PetscValidPointer(u, 2); *u = prob->u;} 19852764a2aaSMatthew G. Knepley if (u_t) {PetscValidPointer(u_t, 3); *u_t = prob->u_t;} 19862764a2aaSMatthew G. Knepley if (u_x) {PetscValidPointer(u_x, 4); *u_x = prob->u_x;} 19872764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 19882764a2aaSMatthew G. Knepley } 19892764a2aaSMatthew G. Knepley 19902764a2aaSMatthew G. Knepley #undef __FUNCT__ 19912764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetWeakFormArrays" 19922764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetWeakFormArrays(PetscDS prob, PetscScalar **f0, PetscScalar **f1, PetscScalar **g0, PetscScalar **g1, PetscScalar **g2, PetscScalar **g3) 19932764a2aaSMatthew G. Knepley { 19942764a2aaSMatthew G. Knepley PetscErrorCode ierr; 19952764a2aaSMatthew G. Knepley 19962764a2aaSMatthew G. Knepley PetscFunctionBegin; 19972764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 19982764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 19992764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 2); *f0 = prob->f0;} 20002764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 3); *f1 = prob->f1;} 20012764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g0;} 20022764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g1;} 20032764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g2;} 20042764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g3;} 20052764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 20062764a2aaSMatthew G. Knepley } 20072764a2aaSMatthew G. Knepley 20082764a2aaSMatthew G. Knepley #undef __FUNCT__ 20092764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetRefCoordArrays" 20102764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetRefCoordArrays(PetscDS prob, PetscReal **x, PetscScalar **refSpaceDer) 20112764a2aaSMatthew G. Knepley { 20122764a2aaSMatthew G. Knepley PetscErrorCode ierr; 20132764a2aaSMatthew G. Knepley 20142764a2aaSMatthew G. Knepley PetscFunctionBegin; 20152764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 20162764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 20172764a2aaSMatthew G. Knepley if (x) {PetscValidPointer(x, 2); *x = prob->x;} 20182764a2aaSMatthew G. Knepley if (refSpaceDer) {PetscValidPointer(refSpaceDer, 3); *refSpaceDer = prob->refSpaceDer;} 20192764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 20202764a2aaSMatthew G. Knepley } 20212764a2aaSMatthew G. Knepley 20222764a2aaSMatthew G. Knepley #undef __FUNCT__ 20232764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroy_Basic" 2024bc4ae4beSMatthew G. Knepley static PetscErrorCode PetscDSDestroy_Basic(PetscDS prob) 20252764a2aaSMatthew G. Knepley { 20262764a2aaSMatthew G. Knepley PetscFunctionBegin; 20272764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 20282764a2aaSMatthew G. Knepley } 20292764a2aaSMatthew G. Knepley 20302764a2aaSMatthew G. Knepley #undef __FUNCT__ 20312764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSInitialize_Basic" 2032bc4ae4beSMatthew G. Knepley static PetscErrorCode PetscDSInitialize_Basic(PetscDS prob) 20332764a2aaSMatthew G. Knepley { 20342764a2aaSMatthew G. Knepley PetscFunctionBegin; 20352764a2aaSMatthew G. Knepley prob->ops->setfromoptions = NULL; 20362764a2aaSMatthew G. Knepley prob->ops->setup = NULL; 20372764a2aaSMatthew G. Knepley prob->ops->view = NULL; 20382764a2aaSMatthew G. Knepley prob->ops->destroy = PetscDSDestroy_Basic; 20392764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 20402764a2aaSMatthew G. Knepley } 20412764a2aaSMatthew G. Knepley 20422764a2aaSMatthew G. Knepley /*MC 20432764a2aaSMatthew G. Knepley PETSCDSBASIC = "basic" - A discrete system with pointwise residual and boundary residual functions 20442764a2aaSMatthew G. Knepley 20452764a2aaSMatthew G. Knepley Level: intermediate 20462764a2aaSMatthew G. Knepley 20472764a2aaSMatthew G. Knepley .seealso: PetscDSType, PetscDSCreate(), PetscDSSetType() 20482764a2aaSMatthew G. Knepley M*/ 20492764a2aaSMatthew G. Knepley 20502764a2aaSMatthew G. Knepley #undef __FUNCT__ 20512764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSCreate_Basic" 20522764a2aaSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscDSCreate_Basic(PetscDS prob) 20532764a2aaSMatthew G. Knepley { 20542764a2aaSMatthew G. Knepley PetscDS_Basic *b; 20552764a2aaSMatthew G. Knepley PetscErrorCode ierr; 20562764a2aaSMatthew G. Knepley 20572764a2aaSMatthew G. Knepley PetscFunctionBegin; 20582764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCSPACE_CLASSID, 1); 20592764a2aaSMatthew G. Knepley ierr = PetscNewLog(prob, &b);CHKERRQ(ierr); 20602764a2aaSMatthew G. Knepley prob->data = b; 20612764a2aaSMatthew G. Knepley 20622764a2aaSMatthew G. Knepley ierr = PetscDSInitialize_Basic(prob);CHKERRQ(ierr); 20632764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 20642764a2aaSMatthew G. Knepley } 2065