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; 3862aa1fc23SMatthew G. Knepley PetscPointFunc *tmpobj, *tmpf; 3872aa1fc23SMatthew G. Knepley PetscPointJac *tmpg; 3882aa1fc23SMatthew G. Knepley PetscBdPointFunc *tmpfbd; 3892aa1fc23SMatthew G. Knepley PetscBdPointJac *tmpgbd; 390194d53e6SMatthew G. Knepley PetscRiemannFunc *tmpr; 3910c2f2876SMatthew G. Knepley void **tmpctx; 392a6cbbb48SMatthew G. Knepley PetscInt Nf = prob->Nf, f, i; 3932764a2aaSMatthew G. Knepley PetscErrorCode ierr; 3942764a2aaSMatthew G. Knepley 3952764a2aaSMatthew G. Knepley PetscFunctionBegin; 3962764a2aaSMatthew G. Knepley if (Nf >= NfNew) PetscFunctionReturn(0); 3972764a2aaSMatthew G. Knepley prob->setup = PETSC_FALSE; 3982764a2aaSMatthew G. Knepley ierr = PetscDSDestroyStructs_Static(prob);CHKERRQ(ierr); 399a6cbbb48SMatthew G. Knepley ierr = PetscMalloc4(NfNew, &tmpd, NfNew, &tmpdbd, NfNew, &tmpi, NfNew*2, &tmpa);CHKERRQ(ierr); 400a6cbbb48SMatthew 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];} 401a6cbbb48SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) {ierr = PetscContainerCreate(PetscObjectComm((PetscObject) prob), (PetscContainer *) &tmpd[f]);CHKERRQ(ierr); 402a6cbbb48SMatthew G. Knepley tmpdbd[f] = NULL; tmpi[f] = PETSC_TRUE; tmpa[f*2+0] = PETSC_FALSE; tmpa[f*2+1] = PETSC_TRUE;} 403a6cbbb48SMatthew G. Knepley ierr = PetscFree4(prob->disc, prob->discBd, prob->implicit, prob->adjacency);CHKERRQ(ierr); 4042764a2aaSMatthew G. Knepley prob->Nf = NfNew; 4052764a2aaSMatthew G. Knepley prob->disc = tmpd; 406a6cbbb48SMatthew G. Knepley prob->discBd = tmpdbd; 407249df284SMatthew G. Knepley prob->implicit = tmpi; 408a6cbbb48SMatthew G. Knepley prob->adjacency = tmpa; 4090c2f2876SMatthew G. Knepley ierr = PetscCalloc5(NfNew, &tmpobj, NfNew*2, &tmpf, NfNew*NfNew*4, &tmpg, NfNew, &tmpr, NfNew, &tmpctx);CHKERRQ(ierr); 4102764a2aaSMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpobj[f] = prob->obj[f]; 4112764a2aaSMatthew G. Knepley for (f = 0; f < Nf*2; ++f) tmpf[f] = prob->f[f]; 4122764a2aaSMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpg[f] = prob->g[f]; 4130c2f2876SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpr[f] = prob->r[f]; 4140c2f2876SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpctx[f] = prob->ctx[f]; 4152764a2aaSMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpobj[f] = NULL; 4162764a2aaSMatthew G. Knepley for (f = Nf*2; f < NfNew*2; ++f) tmpf[f] = NULL; 4172764a2aaSMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpg[f] = NULL; 4180c2f2876SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpr[f] = NULL; 4190c2f2876SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpctx[f] = NULL; 4200c2f2876SMatthew G. Knepley ierr = PetscFree5(prob->obj, prob->f, prob->g, prob->r, prob->ctx);CHKERRQ(ierr); 4212764a2aaSMatthew G. Knepley prob->obj = tmpobj; 4222764a2aaSMatthew G. Knepley prob->f = tmpf; 4232764a2aaSMatthew G. Knepley prob->g = tmpg; 4240c2f2876SMatthew G. Knepley prob->r = tmpr; 4250c2f2876SMatthew G. Knepley prob->ctx = tmpctx; 4262764a2aaSMatthew G. Knepley ierr = PetscCalloc2(NfNew*2, &tmpfbd, NfNew*NfNew*4, &tmpgbd);CHKERRQ(ierr); 4272764a2aaSMatthew G. Knepley for (f = 0; f < Nf*2; ++f) tmpfbd[f] = prob->fBd[f]; 4282764a2aaSMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpgbd[f] = prob->gBd[f]; 4292764a2aaSMatthew G. Knepley for (f = Nf*2; f < NfNew*2; ++f) tmpfbd[f] = NULL; 4302764a2aaSMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgbd[f] = NULL; 4312764a2aaSMatthew G. Knepley ierr = PetscFree2(prob->fBd, prob->gBd);CHKERRQ(ierr); 4322764a2aaSMatthew G. Knepley prob->fBd = tmpfbd; 4332764a2aaSMatthew G. Knepley prob->gBd = tmpgbd; 4342764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4352764a2aaSMatthew G. Knepley } 4362764a2aaSMatthew G. Knepley 4372764a2aaSMatthew G. Knepley #undef __FUNCT__ 4382764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroy" 4392764a2aaSMatthew G. Knepley /*@ 4402764a2aaSMatthew G. Knepley PetscDSDestroy - Destroys a PetscDS object 4412764a2aaSMatthew G. Knepley 4422764a2aaSMatthew G. Knepley Collective on PetscDS 4432764a2aaSMatthew G. Knepley 4442764a2aaSMatthew G. Knepley Input Parameter: 4452764a2aaSMatthew G. Knepley . prob - the PetscDS object to destroy 4462764a2aaSMatthew G. Knepley 4472764a2aaSMatthew G. Knepley Level: developer 4482764a2aaSMatthew G. Knepley 4492764a2aaSMatthew G. Knepley .seealso PetscDSView() 4502764a2aaSMatthew G. Knepley @*/ 4512764a2aaSMatthew G. Knepley PetscErrorCode PetscDSDestroy(PetscDS *prob) 4522764a2aaSMatthew G. Knepley { 4532764a2aaSMatthew G. Knepley PetscInt f; 4542764a2aaSMatthew G. Knepley PetscErrorCode ierr; 4552764a2aaSMatthew G. Knepley 4562764a2aaSMatthew G. Knepley PetscFunctionBegin; 4572764a2aaSMatthew G. Knepley if (!*prob) PetscFunctionReturn(0); 4582764a2aaSMatthew G. Knepley PetscValidHeaderSpecific((*prob), PETSCDS_CLASSID, 1); 4592764a2aaSMatthew G. Knepley 4602764a2aaSMatthew G. Knepley if (--((PetscObject)(*prob))->refct > 0) {*prob = 0; PetscFunctionReturn(0);} 4612764a2aaSMatthew G. Knepley ((PetscObject) (*prob))->refct = 0; 4622764a2aaSMatthew G. Knepley ierr = PetscDSDestroyStructs_Static(*prob);CHKERRQ(ierr); 4632764a2aaSMatthew G. Knepley for (f = 0; f < (*prob)->Nf; ++f) { 4642764a2aaSMatthew G. Knepley ierr = PetscObjectDereference((*prob)->disc[f]);CHKERRQ(ierr); 4652764a2aaSMatthew G. Knepley ierr = PetscObjectDereference((*prob)->discBd[f]);CHKERRQ(ierr); 4662764a2aaSMatthew G. Knepley } 467a6cbbb48SMatthew G. Knepley ierr = PetscFree4((*prob)->disc, (*prob)->discBd, (*prob)->implicit, (*prob)->adjacency);CHKERRQ(ierr); 4680c2f2876SMatthew G. Knepley ierr = PetscFree5((*prob)->obj,(*prob)->f,(*prob)->g,(*prob)->r,(*prob)->ctx);CHKERRQ(ierr); 4692764a2aaSMatthew G. Knepley ierr = PetscFree2((*prob)->fBd,(*prob)->gBd);CHKERRQ(ierr); 4702764a2aaSMatthew G. Knepley if ((*prob)->ops->destroy) {ierr = (*(*prob)->ops->destroy)(*prob);CHKERRQ(ierr);} 4712764a2aaSMatthew G. Knepley ierr = PetscHeaderDestroy(prob);CHKERRQ(ierr); 4722764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4732764a2aaSMatthew G. Knepley } 4742764a2aaSMatthew G. Knepley 4752764a2aaSMatthew G. Knepley #undef __FUNCT__ 4762764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSCreate" 4772764a2aaSMatthew G. Knepley /*@ 4782764a2aaSMatthew G. Knepley PetscDSCreate - Creates an empty PetscDS object. The type can then be set with PetscDSSetType(). 4792764a2aaSMatthew G. Knepley 4802764a2aaSMatthew G. Knepley Collective on MPI_Comm 4812764a2aaSMatthew G. Knepley 4822764a2aaSMatthew G. Knepley Input Parameter: 4832764a2aaSMatthew G. Knepley . comm - The communicator for the PetscDS object 4842764a2aaSMatthew G. Knepley 4852764a2aaSMatthew G. Knepley Output Parameter: 4862764a2aaSMatthew G. Knepley . prob - The PetscDS object 4872764a2aaSMatthew G. Knepley 4882764a2aaSMatthew G. Knepley Level: beginner 4892764a2aaSMatthew G. Knepley 4902764a2aaSMatthew G. Knepley .seealso: PetscDSSetType(), PETSCDSBASIC 4912764a2aaSMatthew G. Knepley @*/ 4922764a2aaSMatthew G. Knepley PetscErrorCode PetscDSCreate(MPI_Comm comm, PetscDS *prob) 4932764a2aaSMatthew G. Knepley { 4942764a2aaSMatthew G. Knepley PetscDS p; 4952764a2aaSMatthew G. Knepley PetscErrorCode ierr; 4962764a2aaSMatthew G. Knepley 4972764a2aaSMatthew G. Knepley PetscFunctionBegin; 4982764a2aaSMatthew G. Knepley PetscValidPointer(prob, 2); 4992764a2aaSMatthew G. Knepley *prob = NULL; 5002764a2aaSMatthew G. Knepley ierr = PetscDSInitializePackage();CHKERRQ(ierr); 5012764a2aaSMatthew G. Knepley 50273107ff1SLisandro Dalcin ierr = PetscHeaderCreate(p, PETSCDS_CLASSID, "PetscDS", "Discrete System", "PetscDS", comm, PetscDSDestroy, PetscDSView);CHKERRQ(ierr); 5032764a2aaSMatthew G. Knepley 5042764a2aaSMatthew G. Knepley p->Nf = 0; 5052764a2aaSMatthew G. Knepley p->setup = PETSC_FALSE; 5062764a2aaSMatthew G. Knepley 5072764a2aaSMatthew G. Knepley *prob = p; 5082764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5092764a2aaSMatthew G. Knepley } 5102764a2aaSMatthew G. Knepley 5112764a2aaSMatthew G. Knepley #undef __FUNCT__ 5122764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetNumFields" 513bc4ae4beSMatthew G. Knepley /*@ 514bc4ae4beSMatthew G. Knepley PetscDSGetNumFields - Returns the number of fields in the DS 515bc4ae4beSMatthew G. Knepley 516bc4ae4beSMatthew G. Knepley Not collective 517bc4ae4beSMatthew G. Knepley 518bc4ae4beSMatthew G. Knepley Input Parameter: 519bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 520bc4ae4beSMatthew G. Knepley 521bc4ae4beSMatthew G. Knepley Output Parameter: 522bc4ae4beSMatthew G. Knepley . Nf - The number of fields 523bc4ae4beSMatthew G. Knepley 524bc4ae4beSMatthew G. Knepley Level: beginner 525bc4ae4beSMatthew G. Knepley 526bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetSpatialDimension(), PetscDSCreate() 527bc4ae4beSMatthew G. Knepley @*/ 5282764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetNumFields(PetscDS prob, PetscInt *Nf) 5292764a2aaSMatthew G. Knepley { 5302764a2aaSMatthew G. Knepley PetscFunctionBegin; 5312764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 5322764a2aaSMatthew G. Knepley PetscValidPointer(Nf, 2); 5332764a2aaSMatthew G. Knepley *Nf = prob->Nf; 5342764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5352764a2aaSMatthew G. Knepley } 5362764a2aaSMatthew G. Knepley 5372764a2aaSMatthew G. Knepley #undef __FUNCT__ 5382764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetSpatialDimension" 539bc4ae4beSMatthew G. Knepley /*@ 540bc4ae4beSMatthew G. Knepley PetscDSGetSpatialDimension - Returns the spatial dimension of the DS 541bc4ae4beSMatthew G. Knepley 542bc4ae4beSMatthew G. Knepley Not collective 543bc4ae4beSMatthew G. Knepley 544bc4ae4beSMatthew G. Knepley Input Parameter: 545bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 546bc4ae4beSMatthew G. Knepley 547bc4ae4beSMatthew G. Knepley Output Parameter: 548bc4ae4beSMatthew G. Knepley . dim - The spatial dimension 549bc4ae4beSMatthew G. Knepley 550bc4ae4beSMatthew G. Knepley Level: beginner 551bc4ae4beSMatthew G. Knepley 552bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 553bc4ae4beSMatthew G. Knepley @*/ 5542764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetSpatialDimension(PetscDS prob, PetscInt *dim) 5552764a2aaSMatthew G. Knepley { 5562764a2aaSMatthew G. Knepley PetscErrorCode ierr; 5572764a2aaSMatthew G. Knepley 5582764a2aaSMatthew G. Knepley PetscFunctionBegin; 5592764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 5602764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 5612764a2aaSMatthew G. Knepley *dim = 0; 5629de99aefSMatthew G. Knepley if (prob->Nf) { 5639de99aefSMatthew G. Knepley PetscObject obj; 5649de99aefSMatthew G. Knepley PetscClassId id; 5659de99aefSMatthew G. Knepley 5669de99aefSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, 0, &obj);CHKERRQ(ierr); 5679de99aefSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 5689de99aefSMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEGetSpatialDimension((PetscFE) obj, dim);CHKERRQ(ierr);} 5699de99aefSMatthew G. Knepley else if (id == PETSCFV_CLASSID) {ierr = PetscFVGetSpatialDimension((PetscFV) obj, dim);CHKERRQ(ierr);} 5709de99aefSMatthew G. Knepley else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", 0); 5719de99aefSMatthew G. Knepley } 5722764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5732764a2aaSMatthew G. Knepley } 5742764a2aaSMatthew G. Knepley 5752764a2aaSMatthew G. Knepley #undef __FUNCT__ 5762764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalDimension" 577bc4ae4beSMatthew G. Knepley /*@ 578bc4ae4beSMatthew G. Knepley PetscDSGetTotalDimension - Returns the total size of the approximation space for this system 579bc4ae4beSMatthew G. Knepley 580bc4ae4beSMatthew G. Knepley Not collective 581bc4ae4beSMatthew G. Knepley 582bc4ae4beSMatthew G. Knepley Input Parameter: 583bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 584bc4ae4beSMatthew G. Knepley 585bc4ae4beSMatthew G. Knepley Output Parameter: 586bc4ae4beSMatthew G. Knepley . dim - The total problem dimension 587bc4ae4beSMatthew G. Knepley 588bc4ae4beSMatthew G. Knepley Level: beginner 589bc4ae4beSMatthew G. Knepley 590bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 591bc4ae4beSMatthew G. Knepley @*/ 5922764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalDimension(PetscDS prob, PetscInt *dim) 5932764a2aaSMatthew G. Knepley { 5942764a2aaSMatthew G. Knepley PetscErrorCode ierr; 5952764a2aaSMatthew G. Knepley 5962764a2aaSMatthew G. Knepley PetscFunctionBegin; 5972764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 5982764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 5992764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 6002764a2aaSMatthew G. Knepley *dim = prob->totDim; 6012764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6022764a2aaSMatthew G. Knepley } 6032764a2aaSMatthew G. Knepley 6042764a2aaSMatthew G. Knepley #undef __FUNCT__ 6052764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalBdDimension" 606bc4ae4beSMatthew G. Knepley /*@ 607c3ac4435SMatthew G. Knepley PetscDSGetTotalBdDimension - Returns the total size of the boundary approximation space for this system 608bc4ae4beSMatthew G. Knepley 609bc4ae4beSMatthew G. Knepley Not collective 610bc4ae4beSMatthew G. Knepley 611bc4ae4beSMatthew G. Knepley Input Parameter: 612bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 613bc4ae4beSMatthew G. Knepley 614bc4ae4beSMatthew G. Knepley Output Parameter: 615bc4ae4beSMatthew G. Knepley . dim - The total boundary problem dimension 616bc4ae4beSMatthew G. Knepley 617bc4ae4beSMatthew G. Knepley Level: beginner 618bc4ae4beSMatthew G. Knepley 619bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 620bc4ae4beSMatthew G. Knepley @*/ 6212764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalBdDimension(PetscDS prob, PetscInt *dim) 6222764a2aaSMatthew G. Knepley { 6232764a2aaSMatthew G. Knepley PetscErrorCode ierr; 6242764a2aaSMatthew G. Knepley 6252764a2aaSMatthew G. Knepley PetscFunctionBegin; 6262764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6272764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 6282764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 6292764a2aaSMatthew G. Knepley *dim = prob->totDimBd; 6302764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6312764a2aaSMatthew G. Knepley } 6322764a2aaSMatthew G. Knepley 6332764a2aaSMatthew G. Knepley #undef __FUNCT__ 6342764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalComponents" 635bc4ae4beSMatthew G. Knepley /*@ 636bc4ae4beSMatthew G. Knepley PetscDSGetTotalComponents - Returns the total number of components in this system 637bc4ae4beSMatthew G. Knepley 638bc4ae4beSMatthew G. Knepley Not collective 639bc4ae4beSMatthew G. Knepley 640bc4ae4beSMatthew G. Knepley Input Parameter: 641bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 642bc4ae4beSMatthew G. Knepley 643bc4ae4beSMatthew G. Knepley Output Parameter: 644bc4ae4beSMatthew G. Knepley . dim - The total number of components 645bc4ae4beSMatthew G. Knepley 646bc4ae4beSMatthew G. Knepley Level: beginner 647bc4ae4beSMatthew G. Knepley 648bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 649bc4ae4beSMatthew G. Knepley @*/ 6502764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalComponents(PetscDS prob, PetscInt *Nc) 6512764a2aaSMatthew G. Knepley { 6522764a2aaSMatthew G. Knepley PetscErrorCode ierr; 6532764a2aaSMatthew G. Knepley 6542764a2aaSMatthew G. Knepley PetscFunctionBegin; 6552764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6562764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 6572764a2aaSMatthew G. Knepley PetscValidPointer(Nc, 2); 6582764a2aaSMatthew G. Knepley *Nc = prob->totComp; 6592764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6602764a2aaSMatthew G. Knepley } 6612764a2aaSMatthew G. Knepley 6622764a2aaSMatthew G. Knepley #undef __FUNCT__ 6632764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetDiscretization" 664bc4ae4beSMatthew G. Knepley /*@ 665bc4ae4beSMatthew G. Knepley PetscDSGetDiscretization - Returns the discretization object for the given field 666bc4ae4beSMatthew G. Knepley 667bc4ae4beSMatthew G. Knepley Not collective 668bc4ae4beSMatthew G. Knepley 669bc4ae4beSMatthew G. Knepley Input Parameters: 670bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 671bc4ae4beSMatthew G. Knepley - f - The field number 672bc4ae4beSMatthew G. Knepley 673bc4ae4beSMatthew G. Knepley Output Parameter: 674bc4ae4beSMatthew G. Knepley . disc - The discretization object 675bc4ae4beSMatthew G. Knepley 676bc4ae4beSMatthew G. Knepley Level: beginner 677bc4ae4beSMatthew G. Knepley 678bc4ae4beSMatthew G. Knepley .seealso: PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 679bc4ae4beSMatthew G. Knepley @*/ 6802764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetDiscretization(PetscDS prob, PetscInt f, PetscObject *disc) 6812764a2aaSMatthew G. Knepley { 6822764a2aaSMatthew G. Knepley PetscFunctionBegin; 6832764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6842764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 6852764a2aaSMatthew 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); 6862764a2aaSMatthew G. Knepley *disc = prob->disc[f]; 6872764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6882764a2aaSMatthew G. Knepley } 6892764a2aaSMatthew G. Knepley 6902764a2aaSMatthew G. Knepley #undef __FUNCT__ 6912764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdDiscretization" 692bc4ae4beSMatthew G. Knepley /*@ 693bc4ae4beSMatthew G. Knepley PetscDSGetBdDiscretization - Returns the boundary discretization object for the given field 694bc4ae4beSMatthew G. Knepley 695bc4ae4beSMatthew G. Knepley Not collective 696bc4ae4beSMatthew G. Knepley 697bc4ae4beSMatthew G. Knepley Input Parameters: 698bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 699bc4ae4beSMatthew G. Knepley - f - The field number 700bc4ae4beSMatthew G. Knepley 701bc4ae4beSMatthew G. Knepley Output Parameter: 702bc4ae4beSMatthew G. Knepley . disc - The boundary discretization object 703bc4ae4beSMatthew G. Knepley 704bc4ae4beSMatthew G. Knepley Level: beginner 705bc4ae4beSMatthew G. Knepley 706bc4ae4beSMatthew G. Knepley .seealso: PetscDSSetBdDiscretization(), PetscDSAddBdDiscretization(), PetscDSGetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 707bc4ae4beSMatthew G. Knepley @*/ 7082764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdDiscretization(PetscDS prob, PetscInt f, PetscObject *disc) 7092764a2aaSMatthew G. Knepley { 7102764a2aaSMatthew G. Knepley PetscFunctionBegin; 7112764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7122764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 7132764a2aaSMatthew 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); 7142764a2aaSMatthew G. Knepley *disc = prob->discBd[f]; 7152764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7162764a2aaSMatthew G. Knepley } 7172764a2aaSMatthew G. Knepley 7182764a2aaSMatthew G. Knepley #undef __FUNCT__ 7192764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetDiscretization" 720bc4ae4beSMatthew G. Knepley /*@ 721bc4ae4beSMatthew G. Knepley PetscDSSetDiscretization - Sets the discretization object for the given field 722bc4ae4beSMatthew G. Knepley 723bc4ae4beSMatthew G. Knepley Not collective 724bc4ae4beSMatthew G. Knepley 725bc4ae4beSMatthew G. Knepley Input Parameters: 726bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 727bc4ae4beSMatthew G. Knepley . f - The field number 728bc4ae4beSMatthew G. Knepley - disc - The discretization object 729bc4ae4beSMatthew G. Knepley 730bc4ae4beSMatthew G. Knepley Level: beginner 731bc4ae4beSMatthew G. Knepley 732bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 733bc4ae4beSMatthew G. Knepley @*/ 7342764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetDiscretization(PetscDS prob, PetscInt f, PetscObject disc) 7352764a2aaSMatthew G. Knepley { 7362764a2aaSMatthew G. Knepley PetscErrorCode ierr; 7372764a2aaSMatthew G. Knepley 7382764a2aaSMatthew G. Knepley PetscFunctionBegin; 7392764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7402764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 7412764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 7422764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 7432764a2aaSMatthew G. Knepley if (prob->disc[f]) {ierr = PetscObjectDereference(prob->disc[f]);CHKERRQ(ierr);} 7442764a2aaSMatthew G. Knepley prob->disc[f] = disc; 7452764a2aaSMatthew G. Knepley ierr = PetscObjectReference(disc);CHKERRQ(ierr); 746249df284SMatthew G. Knepley { 747249df284SMatthew G. Knepley PetscClassId id; 748249df284SMatthew G. Knepley 749249df284SMatthew G. Knepley ierr = PetscObjectGetClassId(disc, &id);CHKERRQ(ierr); 750a6cbbb48SMatthew G. Knepley if (id == PETSCFV_CLASSID) { 751a6cbbb48SMatthew G. Knepley prob->implicit[f] = PETSC_FALSE; 752a6cbbb48SMatthew G. Knepley prob->adjacency[f*2+0] = PETSC_TRUE; 753a6cbbb48SMatthew G. Knepley prob->adjacency[f*2+1] = PETSC_FALSE; 754a6cbbb48SMatthew G. Knepley } 755249df284SMatthew G. Knepley } 7562764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7572764a2aaSMatthew G. Knepley } 7582764a2aaSMatthew G. Knepley 7592764a2aaSMatthew G. Knepley #undef __FUNCT__ 7602764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdDiscretization" 761bc4ae4beSMatthew G. Knepley /*@ 762bc4ae4beSMatthew G. Knepley PetscDSSetBdDiscretization - Sets the boundary discretization object for the given field 763bc4ae4beSMatthew G. Knepley 764bc4ae4beSMatthew G. Knepley Not collective 765bc4ae4beSMatthew G. Knepley 766bc4ae4beSMatthew G. Knepley Input Parameters: 767bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 768bc4ae4beSMatthew G. Knepley . f - The field number 769bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object 770bc4ae4beSMatthew G. Knepley 771bc4ae4beSMatthew G. Knepley Level: beginner 772bc4ae4beSMatthew G. Knepley 773bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetBdDiscretization(), PetscDSAddBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 774bc4ae4beSMatthew G. Knepley @*/ 7752764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdDiscretization(PetscDS prob, PetscInt f, PetscObject disc) 7762764a2aaSMatthew G. Knepley { 7772764a2aaSMatthew G. Knepley PetscErrorCode ierr; 7782764a2aaSMatthew G. Knepley 7792764a2aaSMatthew G. Knepley PetscFunctionBegin; 7802764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7812764a2aaSMatthew G. Knepley if (disc) PetscValidPointer(disc, 3); 7822764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 7832764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 7842764a2aaSMatthew G. Knepley if (prob->discBd[f]) {ierr = PetscObjectDereference(prob->discBd[f]);CHKERRQ(ierr);} 7852764a2aaSMatthew G. Knepley prob->discBd[f] = disc; 7862764a2aaSMatthew G. Knepley ierr = PetscObjectReference(disc);CHKERRQ(ierr); 7872764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7882764a2aaSMatthew G. Knepley } 7892764a2aaSMatthew G. Knepley 7902764a2aaSMatthew G. Knepley #undef __FUNCT__ 7912764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSAddDiscretization" 792bc4ae4beSMatthew G. Knepley /*@ 793bc4ae4beSMatthew G. Knepley PetscDSAddDiscretization - Adds a discretization object 794bc4ae4beSMatthew G. Knepley 795bc4ae4beSMatthew G. Knepley Not collective 796bc4ae4beSMatthew G. Knepley 797bc4ae4beSMatthew G. Knepley Input Parameters: 798bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 799bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object 800bc4ae4beSMatthew G. Knepley 801bc4ae4beSMatthew G. Knepley Level: beginner 802bc4ae4beSMatthew G. Knepley 803bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSSetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 804bc4ae4beSMatthew G. Knepley @*/ 8052764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddDiscretization(PetscDS prob, PetscObject disc) 8062764a2aaSMatthew G. Knepley { 8072764a2aaSMatthew G. Knepley PetscErrorCode ierr; 8082764a2aaSMatthew G. Knepley 8092764a2aaSMatthew G. Knepley PetscFunctionBegin; 8102764a2aaSMatthew G. Knepley ierr = PetscDSSetDiscretization(prob, prob->Nf, disc);CHKERRQ(ierr); 8112764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8122764a2aaSMatthew G. Knepley } 8132764a2aaSMatthew G. Knepley 8142764a2aaSMatthew G. Knepley #undef __FUNCT__ 8152764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSAddBdDiscretization" 816bc4ae4beSMatthew G. Knepley /*@ 817bc4ae4beSMatthew G. Knepley PetscDSAddBdDiscretization - Adds a boundary discretization object 818bc4ae4beSMatthew G. Knepley 819bc4ae4beSMatthew G. Knepley Not collective 820bc4ae4beSMatthew G. Knepley 821bc4ae4beSMatthew G. Knepley Input Parameters: 822bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 823bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object 824bc4ae4beSMatthew G. Knepley 825bc4ae4beSMatthew G. Knepley Level: beginner 826bc4ae4beSMatthew G. Knepley 827bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetBdDiscretization(), PetscDSSetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 828bc4ae4beSMatthew G. Knepley @*/ 8292764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddBdDiscretization(PetscDS prob, PetscObject disc) 8302764a2aaSMatthew G. Knepley { 8312764a2aaSMatthew G. Knepley PetscErrorCode ierr; 8322764a2aaSMatthew G. Knepley 8332764a2aaSMatthew G. Knepley PetscFunctionBegin; 8342764a2aaSMatthew G. Knepley ierr = PetscDSSetBdDiscretization(prob, prob->Nf, disc);CHKERRQ(ierr); 8352764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8362764a2aaSMatthew G. Knepley } 8372764a2aaSMatthew G. Knepley 8382764a2aaSMatthew G. Knepley #undef __FUNCT__ 839249df284SMatthew G. Knepley #define __FUNCT__ "PetscDSGetImplicit" 840249df284SMatthew G. Knepley /*@ 841249df284SMatthew G. Knepley PetscDSGetImplicit - Returns the flag for implicit solve for this field. This is just a guide for IMEX 842249df284SMatthew G. Knepley 843249df284SMatthew G. Knepley Not collective 844249df284SMatthew G. Knepley 845249df284SMatthew G. Knepley Input Parameters: 846249df284SMatthew G. Knepley + prob - The PetscDS object 847249df284SMatthew G. Knepley - f - The field number 848249df284SMatthew G. Knepley 849249df284SMatthew G. Knepley Output Parameter: 850249df284SMatthew G. Knepley . implicit - The flag indicating what kind of solve to use for this field 851249df284SMatthew G. Knepley 852249df284SMatthew G. Knepley Level: developer 853249df284SMatthew G. Knepley 854249df284SMatthew G. Knepley .seealso: PetscDSSetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 855249df284SMatthew G. Knepley @*/ 856249df284SMatthew G. Knepley PetscErrorCode PetscDSGetImplicit(PetscDS prob, PetscInt f, PetscBool *implicit) 857249df284SMatthew G. Knepley { 858249df284SMatthew G. Knepley PetscFunctionBegin; 859249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 860249df284SMatthew G. Knepley PetscValidPointer(implicit, 3); 861249df284SMatthew 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); 862249df284SMatthew G. Knepley *implicit = prob->implicit[f]; 863249df284SMatthew G. Knepley PetscFunctionReturn(0); 864249df284SMatthew G. Knepley } 865249df284SMatthew G. Knepley 866249df284SMatthew G. Knepley #undef __FUNCT__ 867249df284SMatthew G. Knepley #define __FUNCT__ "PetscDSSetImplicit" 868249df284SMatthew G. Knepley /*@ 869249df284SMatthew G. Knepley PetscDSSetImplicit - Set the flag for implicit solve for this field. This is just a guide for IMEX 870249df284SMatthew G. Knepley 871249df284SMatthew G. Knepley Not collective 872249df284SMatthew G. Knepley 873249df284SMatthew G. Knepley Input Parameters: 874249df284SMatthew G. Knepley + prob - The PetscDS object 875249df284SMatthew G. Knepley . f - The field number 876249df284SMatthew G. Knepley - implicit - The flag indicating what kind of solve to use for this field 877249df284SMatthew G. Knepley 878249df284SMatthew G. Knepley Level: developer 879249df284SMatthew G. Knepley 880249df284SMatthew G. Knepley .seealso: PetscDSGetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 881249df284SMatthew G. Knepley @*/ 882249df284SMatthew G. Knepley PetscErrorCode PetscDSSetImplicit(PetscDS prob, PetscInt f, PetscBool implicit) 883249df284SMatthew G. Knepley { 884249df284SMatthew G. Knepley PetscFunctionBegin; 885249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 886249df284SMatthew 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); 887249df284SMatthew G. Knepley prob->implicit[f] = implicit; 888249df284SMatthew G. Knepley PetscFunctionReturn(0); 889249df284SMatthew G. Knepley } 890249df284SMatthew G. Knepley 891249df284SMatthew G. Knepley #undef __FUNCT__ 892a6cbbb48SMatthew G. Knepley #define __FUNCT__ "PetscDSGetAdjacency" 893a6cbbb48SMatthew G. Knepley /*@ 894a6cbbb48SMatthew G. Knepley PetscDSGetAdjacency - Returns the flags for determining variable influence 895a6cbbb48SMatthew G. Knepley 896a6cbbb48SMatthew G. Knepley Not collective 897a6cbbb48SMatthew G. Knepley 898a6cbbb48SMatthew G. Knepley Input Parameters: 899a6cbbb48SMatthew G. Knepley + prob - The PetscDS object 900a6cbbb48SMatthew G. Knepley - f - The field number 901a6cbbb48SMatthew G. Knepley 902a6cbbb48SMatthew G. Knepley Output Parameter: 903a6cbbb48SMatthew G. Knepley + useCone - Flag for variable influence starting with the cone operation 904a6cbbb48SMatthew G. Knepley - useClosure - Flag for variable influence using transitive closure 905a6cbbb48SMatthew G. Knepley 906a6cbbb48SMatthew G. Knepley Note: See the discussion in DMPlexGetAdjacencyUseCone() and DMPlexGetAdjacencyUseClosure() 907a6cbbb48SMatthew G. Knepley 908a6cbbb48SMatthew G. Knepley Level: developer 909a6cbbb48SMatthew G. Knepley 910a6cbbb48SMatthew G. Knepley .seealso: PetscDSSetAdjacency(), DMPlexGetAdjacencyUseCone(), DMPlexGetAdjacencyUseClosure(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 911a6cbbb48SMatthew G. Knepley @*/ 912a6cbbb48SMatthew G. Knepley PetscErrorCode PetscDSGetAdjacency(PetscDS prob, PetscInt f, PetscBool *useCone, PetscBool *useClosure) 913a6cbbb48SMatthew G. Knepley { 914a6cbbb48SMatthew G. Knepley PetscFunctionBegin; 915a6cbbb48SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 916a6cbbb48SMatthew G. Knepley PetscValidPointer(useCone, 3); 917a6cbbb48SMatthew G. Knepley PetscValidPointer(useClosure, 4); 918a6cbbb48SMatthew 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); 919a6cbbb48SMatthew G. Knepley *useCone = prob->adjacency[f*2+0]; 920a6cbbb48SMatthew G. Knepley *useClosure = prob->adjacency[f*2+1]; 921a6cbbb48SMatthew G. Knepley PetscFunctionReturn(0); 922a6cbbb48SMatthew G. Knepley } 923a6cbbb48SMatthew G. Knepley 924a6cbbb48SMatthew G. Knepley #undef __FUNCT__ 925a6cbbb48SMatthew G. Knepley #define __FUNCT__ "PetscDSSetAdjacency" 926a6cbbb48SMatthew G. Knepley /*@ 927a6cbbb48SMatthew G. Knepley PetscDSSetAdjacency - Set the flags for determining variable influence 928a6cbbb48SMatthew G. Knepley 929a6cbbb48SMatthew G. Knepley Not collective 930a6cbbb48SMatthew G. Knepley 931a6cbbb48SMatthew G. Knepley Input Parameters: 932a6cbbb48SMatthew G. Knepley + prob - The PetscDS object 933a6cbbb48SMatthew G. Knepley . f - The field number 934a6cbbb48SMatthew G. Knepley . useCone - Flag for variable influence starting with the cone operation 935a6cbbb48SMatthew G. Knepley - useClosure - Flag for variable influence using transitive closure 936a6cbbb48SMatthew G. Knepley 937a6cbbb48SMatthew G. Knepley Note: See the discussion in DMPlexGetAdjacencyUseCone() and DMPlexGetAdjacencyUseClosure() 938a6cbbb48SMatthew G. Knepley 939a6cbbb48SMatthew G. Knepley Level: developer 940a6cbbb48SMatthew G. Knepley 941a6cbbb48SMatthew G. Knepley .seealso: PetscDSGetAdjacency(), DMPlexGetAdjacencyUseCone(), DMPlexGetAdjacencyUseClosure(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 942a6cbbb48SMatthew G. Knepley @*/ 943a6cbbb48SMatthew G. Knepley PetscErrorCode PetscDSSetAdjacency(PetscDS prob, PetscInt f, PetscBool useCone, PetscBool useClosure) 944a6cbbb48SMatthew G. Knepley { 945a6cbbb48SMatthew G. Knepley PetscFunctionBegin; 946a6cbbb48SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 947a6cbbb48SMatthew 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); 948a6cbbb48SMatthew G. Knepley prob->adjacency[f*2+0] = useCone; 949a6cbbb48SMatthew G. Knepley prob->adjacency[f*2+1] = useClosure; 950a6cbbb48SMatthew G. Knepley PetscFunctionReturn(0); 951a6cbbb48SMatthew G. Knepley } 952a6cbbb48SMatthew G. Knepley 953a6cbbb48SMatthew G. Knepley #undef __FUNCT__ 9542764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetObjective" 9552764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetObjective(PetscDS prob, PetscInt f, 956*30b9ff8bSMatthew G. Knepley void (**obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 957194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 958194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 959*30b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar obj[])) 9602764a2aaSMatthew G. Knepley { 9612764a2aaSMatthew G. Knepley PetscFunctionBegin; 9622764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 9632764a2aaSMatthew G. Knepley PetscValidPointer(obj, 2); 9642764a2aaSMatthew 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); 9652764a2aaSMatthew G. Knepley *obj = prob->obj[f]; 9662764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9672764a2aaSMatthew G. Knepley } 9682764a2aaSMatthew G. Knepley 9692764a2aaSMatthew G. Knepley #undef __FUNCT__ 9702764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetObjective" 9712764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetObjective(PetscDS prob, PetscInt f, 972*30b9ff8bSMatthew G. Knepley void (*obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 973194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 974194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 975*30b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar obj[])) 9762764a2aaSMatthew G. Knepley { 9772764a2aaSMatthew G. Knepley PetscErrorCode ierr; 9782764a2aaSMatthew G. Knepley 9792764a2aaSMatthew G. Knepley PetscFunctionBegin; 9802764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 9812764a2aaSMatthew G. Knepley PetscValidFunction(obj, 2); 9822764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 9832764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 9842764a2aaSMatthew G. Knepley prob->obj[f] = obj; 9852764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9862764a2aaSMatthew G. Knepley } 9872764a2aaSMatthew G. Knepley 9882764a2aaSMatthew G. Knepley #undef __FUNCT__ 9892764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetResidual" 990194d53e6SMatthew G. Knepley /*@C 991194d53e6SMatthew G. Knepley PetscDSGetResidual - Get the pointwise residual function for a given test field 992194d53e6SMatthew G. Knepley 993194d53e6SMatthew G. Knepley Not collective 994194d53e6SMatthew G. Knepley 995194d53e6SMatthew G. Knepley Input Parameters: 996194d53e6SMatthew G. Knepley + prob - The PetscDS 997194d53e6SMatthew G. Knepley - f - The test field number 998194d53e6SMatthew G. Knepley 999194d53e6SMatthew G. Knepley Output Parameters: 1000194d53e6SMatthew G. Knepley + f0 - integrand for the test function term 1001194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 1002194d53e6SMatthew G. Knepley 1003194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1004194d53e6SMatthew G. Knepley 1005194d53e6SMatthew 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) 1006194d53e6SMatthew G. Knepley 1007194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1008194d53e6SMatthew G. Knepley 1009*30b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1010194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1011194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1012*30b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1013194d53e6SMatthew G. Knepley 1014194d53e6SMatthew G. Knepley + dim - the spatial dimension 1015194d53e6SMatthew G. Knepley . Nf - the number of fields 1016194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1017194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1018194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1019194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1020194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1021194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1022194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1023194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1024194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1025194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1026194d53e6SMatthew G. Knepley . t - current time 1027194d53e6SMatthew G. Knepley . x - coordinates of the current point 1028194d53e6SMatthew G. Knepley - f0 - output values at the current point 1029194d53e6SMatthew G. Knepley 1030194d53e6SMatthew G. Knepley Level: intermediate 1031194d53e6SMatthew G. Knepley 1032194d53e6SMatthew G. Knepley .seealso: PetscDSSetResidual() 1033194d53e6SMatthew G. Knepley @*/ 10342764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetResidual(PetscDS prob, PetscInt f, 1035*30b9ff8bSMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1036194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1037194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1038*30b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar f0[]), 1039*30b9ff8bSMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1040194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1041194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1042*30b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar f1[])) 10432764a2aaSMatthew G. Knepley { 10442764a2aaSMatthew G. Knepley PetscFunctionBegin; 10452764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 10462764a2aaSMatthew 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); 10472764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 3); *f0 = prob->f[f*2+0];} 10482764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 4); *f1 = prob->f[f*2+1];} 10492764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 10502764a2aaSMatthew G. Knepley } 10512764a2aaSMatthew G. Knepley 10522764a2aaSMatthew G. Knepley #undef __FUNCT__ 10532764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetResidual" 1054194d53e6SMatthew G. Knepley /*@C 1055194d53e6SMatthew G. Knepley PetscDSSetResidual - Set the pointwise residual function for a given test field 1056194d53e6SMatthew G. Knepley 1057194d53e6SMatthew G. Knepley Not collective 1058194d53e6SMatthew G. Knepley 1059194d53e6SMatthew G. Knepley Input Parameters: 1060194d53e6SMatthew G. Knepley + prob - The PetscDS 1061194d53e6SMatthew G. Knepley . f - The test field number 1062194d53e6SMatthew G. Knepley . f0 - integrand for the test function term 1063194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 1064194d53e6SMatthew G. Knepley 1065194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1066194d53e6SMatthew G. Knepley 1067194d53e6SMatthew 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) 1068194d53e6SMatthew G. Knepley 1069194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1070194d53e6SMatthew G. Knepley 1071*30b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1072194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1073194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1074*30b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1075194d53e6SMatthew G. Knepley 1076194d53e6SMatthew G. Knepley + dim - the spatial dimension 1077194d53e6SMatthew G. Knepley . Nf - the number of fields 1078194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1079194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1080194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1081194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1082194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1083194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1084194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1085194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1086194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1087194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1088194d53e6SMatthew G. Knepley . t - current time 1089194d53e6SMatthew G. Knepley . x - coordinates of the current point 1090194d53e6SMatthew G. Knepley - f0 - output values at the current point 1091194d53e6SMatthew G. Knepley 1092194d53e6SMatthew G. Knepley Level: intermediate 1093194d53e6SMatthew G. Knepley 1094194d53e6SMatthew G. Knepley .seealso: PetscDSGetResidual() 1095194d53e6SMatthew G. Knepley @*/ 10962764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetResidual(PetscDS prob, PetscInt f, 1097*30b9ff8bSMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1098194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1099194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1100*30b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar f0[]), 1101*30b9ff8bSMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1102194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1103194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1104*30b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar f1[])) 11052764a2aaSMatthew G. Knepley { 11062764a2aaSMatthew G. Knepley PetscErrorCode ierr; 11072764a2aaSMatthew G. Knepley 11082764a2aaSMatthew G. Knepley PetscFunctionBegin; 11092764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 11102764a2aaSMatthew G. Knepley PetscValidFunction(f0, 3); 11112764a2aaSMatthew G. Knepley PetscValidFunction(f1, 4); 11122764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 11132764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 11142764a2aaSMatthew G. Knepley prob->f[f*2+0] = f0; 11152764a2aaSMatthew G. Knepley prob->f[f*2+1] = f1; 11162764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 11172764a2aaSMatthew G. Knepley } 11182764a2aaSMatthew G. Knepley 11192764a2aaSMatthew G. Knepley #undef __FUNCT__ 11202764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetJacobian" 1121194d53e6SMatthew G. Knepley /*@C 1122194d53e6SMatthew G. Knepley PetscDSGetJacobian - Get the pointwise Jacobian function for given test and basis field 1123194d53e6SMatthew G. Knepley 1124194d53e6SMatthew G. Knepley Not collective 1125194d53e6SMatthew G. Knepley 1126194d53e6SMatthew G. Knepley Input Parameters: 1127194d53e6SMatthew G. Knepley + prob - The PetscDS 1128194d53e6SMatthew G. Knepley . f - The test field number 1129194d53e6SMatthew G. Knepley - g - The field number 1130194d53e6SMatthew G. Knepley 1131194d53e6SMatthew G. Knepley Output Parameters: 1132194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 1133194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1134194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1135194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1136194d53e6SMatthew G. Knepley 1137194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1138194d53e6SMatthew G. Knepley 1139194d53e6SMatthew 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 1140194d53e6SMatthew G. Knepley 1141194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1142194d53e6SMatthew G. Knepley 1143*30b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1144194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1145194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1146*30b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1147194d53e6SMatthew G. Knepley 1148194d53e6SMatthew G. Knepley + dim - the spatial dimension 1149194d53e6SMatthew G. Knepley . Nf - the number of fields 1150194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1151194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1152194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1153194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1154194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1155194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1156194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1157194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1158194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1159194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1160194d53e6SMatthew G. Knepley . t - current time 11612aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1162194d53e6SMatthew G. Knepley . x - coordinates of the current point 1163194d53e6SMatthew G. Knepley - g0 - output values at the current point 1164194d53e6SMatthew G. Knepley 1165194d53e6SMatthew G. Knepley Level: intermediate 1166194d53e6SMatthew G. Knepley 1167194d53e6SMatthew G. Knepley .seealso: PetscDSSetJacobian() 1168194d53e6SMatthew G. Knepley @*/ 11692764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetJacobian(PetscDS prob, PetscInt f, PetscInt g, 1170*30b9ff8bSMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1171194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1172194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 11732aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]), 1174*30b9ff8bSMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1175194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1176194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 11772aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]), 1178*30b9ff8bSMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1179194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1180194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 11812aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]), 1182*30b9ff8bSMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1183194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1184194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 11852aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[])) 11862764a2aaSMatthew G. Knepley { 11872764a2aaSMatthew G. Knepley PetscFunctionBegin; 11882764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 11892764a2aaSMatthew 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); 11902764a2aaSMatthew 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); 11912764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g[(f*prob->Nf + g)*4+0];} 11922764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g[(f*prob->Nf + g)*4+1];} 11932764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g[(f*prob->Nf + g)*4+2];} 11942764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g[(f*prob->Nf + g)*4+3];} 11952764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 11962764a2aaSMatthew G. Knepley } 11972764a2aaSMatthew G. Knepley 11982764a2aaSMatthew G. Knepley #undef __FUNCT__ 11992764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetJacobian" 1200194d53e6SMatthew G. Knepley /*@C 1201194d53e6SMatthew G. Knepley PetscDSSetJacobian - Set the pointwise Jacobian function for given test and basis fields 1202194d53e6SMatthew G. Knepley 1203194d53e6SMatthew G. Knepley Not collective 1204194d53e6SMatthew G. Knepley 1205194d53e6SMatthew G. Knepley Input Parameters: 1206194d53e6SMatthew G. Knepley + prob - The PetscDS 1207194d53e6SMatthew G. Knepley . f - The test field number 1208194d53e6SMatthew G. Knepley . g - The field number 1209194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 1210194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1211194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1212194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1213194d53e6SMatthew G. Knepley 1214194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1215194d53e6SMatthew G. Knepley 1216194d53e6SMatthew 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 1217194d53e6SMatthew G. Knepley 1218194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1219194d53e6SMatthew G. Knepley 1220*30b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1221194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1222194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1223*30b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1224194d53e6SMatthew G. Knepley 1225194d53e6SMatthew G. Knepley + dim - the spatial dimension 1226194d53e6SMatthew G. Knepley . Nf - the number of fields 1227194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1228194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1229194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1230194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1231194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1232194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1233194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1234194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1235194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1236194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1237194d53e6SMatthew G. Knepley . t - current time 12382aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1239194d53e6SMatthew G. Knepley . x - coordinates of the current point 1240194d53e6SMatthew G. Knepley - g0 - output values at the current point 1241194d53e6SMatthew G. Knepley 1242194d53e6SMatthew G. Knepley Level: intermediate 1243194d53e6SMatthew G. Knepley 1244194d53e6SMatthew G. Knepley .seealso: PetscDSGetJacobian() 1245194d53e6SMatthew G. Knepley @*/ 12462764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetJacobian(PetscDS prob, PetscInt f, PetscInt g, 1247*30b9ff8bSMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 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[], 1250*30b9ff8bSMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]), 1251*30b9ff8bSMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 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[], 1254*30b9ff8bSMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]), 1255*30b9ff8bSMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 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[], 1258*30b9ff8bSMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]), 1259*30b9ff8bSMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1260194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1261194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1262*30b9ff8bSMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[])) 12632764a2aaSMatthew G. Knepley { 12642764a2aaSMatthew G. Knepley PetscErrorCode ierr; 12652764a2aaSMatthew G. Knepley 12662764a2aaSMatthew G. Knepley PetscFunctionBegin; 12672764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 12682764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 12692764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 12702764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 12712764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 12722764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 12732764a2aaSMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 12742764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 12752764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+0] = g0; 12762764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+1] = g1; 12772764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+2] = g2; 12782764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+3] = g3; 12792764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 12802764a2aaSMatthew G. Knepley } 12812764a2aaSMatthew G. Knepley 12822764a2aaSMatthew G. Knepley #undef __FUNCT__ 12830c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSGetRiemannSolver" 12840c2f2876SMatthew G. Knepley /*@C 12850c2f2876SMatthew G. Knepley PetscDSGetRiemannSolver - Returns the Riemann solver for the given field 12860c2f2876SMatthew G. Knepley 12870c2f2876SMatthew G. Knepley Not collective 12880c2f2876SMatthew G. Knepley 12890c2f2876SMatthew G. Knepley Input Arguments: 12900c2f2876SMatthew G. Knepley + prob - The PetscDS object 12910c2f2876SMatthew G. Knepley - f - The field number 12920c2f2876SMatthew G. Knepley 12930c2f2876SMatthew G. Knepley Output Argument: 12940c2f2876SMatthew G. Knepley . r - Riemann solver 12950c2f2876SMatthew G. Knepley 12960c2f2876SMatthew G. Knepley Calling sequence for r: 12970c2f2876SMatthew G. Knepley 12985db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 12990c2f2876SMatthew G. Knepley 13005db36cf9SMatthew G. Knepley + dim - The spatial dimension 13015db36cf9SMatthew G. Knepley . Nf - The number of fields 13025db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 13030c2f2876SMatthew G. Knepley . n - The normal vector to the interface 13040c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 13050c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 13060c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 13070c2f2876SMatthew G. Knepley - ctx - optional user context 13080c2f2876SMatthew G. Knepley 13090c2f2876SMatthew G. Knepley Level: intermediate 13100c2f2876SMatthew G. Knepley 13110c2f2876SMatthew G. Knepley .seealso: PetscDSSetRiemannSolver() 13120c2f2876SMatthew G. Knepley @*/ 13130c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetRiemannSolver(PetscDS prob, PetscInt f, 13145db36cf9SMatthew G. Knepley void (**r)(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx)) 13150c2f2876SMatthew G. Knepley { 13160c2f2876SMatthew G. Knepley PetscFunctionBegin; 13170c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 13180c2f2876SMatthew 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); 13190c2f2876SMatthew G. Knepley PetscValidPointer(r, 3); 13200c2f2876SMatthew G. Knepley *r = prob->r[f]; 13210c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 13220c2f2876SMatthew G. Knepley } 13230c2f2876SMatthew G. Knepley 13240c2f2876SMatthew G. Knepley #undef __FUNCT__ 13250c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSSetRiemannSolver" 13260c2f2876SMatthew G. Knepley /*@C 13270c2f2876SMatthew G. Knepley PetscDSSetRiemannSolver - Sets the Riemann solver for the given field 13280c2f2876SMatthew G. Knepley 13290c2f2876SMatthew G. Knepley Not collective 13300c2f2876SMatthew G. Knepley 13310c2f2876SMatthew G. Knepley Input Arguments: 13320c2f2876SMatthew G. Knepley + prob - The PetscDS object 13330c2f2876SMatthew G. Knepley . f - The field number 13340c2f2876SMatthew G. Knepley - r - Riemann solver 13350c2f2876SMatthew G. Knepley 13360c2f2876SMatthew G. Knepley Calling sequence for r: 13370c2f2876SMatthew G. Knepley 13385db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 13390c2f2876SMatthew G. Knepley 13405db36cf9SMatthew G. Knepley + dim - The spatial dimension 13415db36cf9SMatthew G. Knepley . Nf - The number of fields 13425db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 13430c2f2876SMatthew G. Knepley . n - The normal vector to the interface 13440c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 13450c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 13460c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 13470c2f2876SMatthew G. Knepley - ctx - optional user context 13480c2f2876SMatthew G. Knepley 13490c2f2876SMatthew G. Knepley Level: intermediate 13500c2f2876SMatthew G. Knepley 13510c2f2876SMatthew G. Knepley .seealso: PetscDSGetRiemannSolver() 13520c2f2876SMatthew G. Knepley @*/ 13530c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetRiemannSolver(PetscDS prob, PetscInt f, 13545db36cf9SMatthew G. Knepley void (*r)(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx)) 13550c2f2876SMatthew G. Knepley { 13560c2f2876SMatthew G. Knepley PetscErrorCode ierr; 13570c2f2876SMatthew G. Knepley 13580c2f2876SMatthew G. Knepley PetscFunctionBegin; 13590c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 13600c2f2876SMatthew G. Knepley PetscValidFunction(r, 3); 13610c2f2876SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 13620c2f2876SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 13630c2f2876SMatthew G. Knepley prob->r[f] = r; 13640c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 13650c2f2876SMatthew G. Knepley } 13660c2f2876SMatthew G. Knepley 13670c2f2876SMatthew G. Knepley #undef __FUNCT__ 13680c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSGetContext" 13690c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetContext(PetscDS prob, PetscInt f, void **ctx) 13700c2f2876SMatthew G. Knepley { 13710c2f2876SMatthew G. Knepley PetscFunctionBegin; 13720c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 13730c2f2876SMatthew 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); 13740c2f2876SMatthew G. Knepley PetscValidPointer(ctx, 3); 13750c2f2876SMatthew G. Knepley *ctx = prob->ctx[f]; 13760c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 13770c2f2876SMatthew G. Knepley } 13780c2f2876SMatthew G. Knepley 13790c2f2876SMatthew G. Knepley #undef __FUNCT__ 13800c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSSetContext" 13810c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetContext(PetscDS prob, PetscInt f, void *ctx) 13820c2f2876SMatthew G. Knepley { 13830c2f2876SMatthew G. Knepley PetscErrorCode ierr; 13840c2f2876SMatthew G. Knepley 13850c2f2876SMatthew G. Knepley PetscFunctionBegin; 13860c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 13870c2f2876SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 13880c2f2876SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 13890c2f2876SMatthew G. Knepley prob->ctx[f] = ctx; 13900c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 13910c2f2876SMatthew G. Knepley } 13920c2f2876SMatthew G. Knepley 13930c2f2876SMatthew G. Knepley #undef __FUNCT__ 13942764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdResidual" 1395194d53e6SMatthew G. Knepley /*@C 1396194d53e6SMatthew G. Knepley PetscDSGetBdResidual - Get the pointwise boundary residual function for a given test field 1397194d53e6SMatthew G. Knepley 1398194d53e6SMatthew G. Knepley Not collective 1399194d53e6SMatthew G. Knepley 1400194d53e6SMatthew G. Knepley Input Parameters: 1401194d53e6SMatthew G. Knepley + prob - The PetscDS 1402194d53e6SMatthew G. Knepley - f - The test field number 1403194d53e6SMatthew G. Knepley 1404194d53e6SMatthew G. Knepley Output Parameters: 1405194d53e6SMatthew G. Knepley + f0 - boundary integrand for the test function term 1406194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 1407194d53e6SMatthew G. Knepley 1408194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1409194d53e6SMatthew G. Knepley 1410194d53e6SMatthew 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 1411194d53e6SMatthew G. Knepley 1412194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1413194d53e6SMatthew G. Knepley 1414*30b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1415194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1416194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1417*30b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 1418194d53e6SMatthew G. Knepley 1419194d53e6SMatthew G. Knepley + dim - the spatial dimension 1420194d53e6SMatthew G. Knepley . Nf - the number of fields 1421194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1422194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1423194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1424194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1425194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1426194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1427194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1428194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1429194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1430194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1431194d53e6SMatthew G. Knepley . t - current time 1432194d53e6SMatthew G. Knepley . x - coordinates of the current point 1433194d53e6SMatthew G. Knepley . n - unit normal at the current point 1434194d53e6SMatthew G. Knepley - f0 - output values at the current point 1435194d53e6SMatthew G. Knepley 1436194d53e6SMatthew G. Knepley Level: intermediate 1437194d53e6SMatthew G. Knepley 1438194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdResidual() 1439194d53e6SMatthew G. Knepley @*/ 14402764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdResidual(PetscDS prob, PetscInt f, 1441*30b9ff8bSMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 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[], 1444*30b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]), 1445*30b9ff8bSMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1446194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1447194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1448*30b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f1[])) 14492764a2aaSMatthew G. Knepley { 14502764a2aaSMatthew G. Knepley PetscFunctionBegin; 14512764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 14522764a2aaSMatthew 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); 14532764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 3); *f0 = prob->fBd[f*2+0];} 14542764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 4); *f1 = prob->fBd[f*2+1];} 14552764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 14562764a2aaSMatthew G. Knepley } 14572764a2aaSMatthew G. Knepley 14582764a2aaSMatthew G. Knepley #undef __FUNCT__ 14592764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdResidual" 1460194d53e6SMatthew G. Knepley /*@C 1461194d53e6SMatthew G. Knepley PetscDSSetBdResidual - Get the pointwise boundary residual function for a given test field 1462194d53e6SMatthew G. Knepley 1463194d53e6SMatthew G. Knepley Not collective 1464194d53e6SMatthew G. Knepley 1465194d53e6SMatthew G. Knepley Input Parameters: 1466194d53e6SMatthew G. Knepley + prob - The PetscDS 1467194d53e6SMatthew G. Knepley . f - The test field number 1468194d53e6SMatthew G. Knepley . f0 - boundary integrand for the test function term 1469194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 1470194d53e6SMatthew G. Knepley 1471194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1472194d53e6SMatthew G. Knepley 1473194d53e6SMatthew 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 1474194d53e6SMatthew G. Knepley 1475194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1476194d53e6SMatthew G. Knepley 1477*30b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1478194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1479194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1480*30b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 1481194d53e6SMatthew G. Knepley 1482194d53e6SMatthew G. Knepley + dim - the spatial dimension 1483194d53e6SMatthew G. Knepley . Nf - the number of fields 1484194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1485194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1486194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1487194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1488194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1489194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1490194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1491194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1492194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1493194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1494194d53e6SMatthew G. Knepley . t - current time 1495194d53e6SMatthew G. Knepley . x - coordinates of the current point 1496194d53e6SMatthew G. Knepley . n - unit normal at the current point 1497194d53e6SMatthew G. Knepley - f0 - output values at the current point 1498194d53e6SMatthew G. Knepley 1499194d53e6SMatthew G. Knepley Level: intermediate 1500194d53e6SMatthew G. Knepley 1501194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdResidual() 1502194d53e6SMatthew G. Knepley @*/ 15032764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdResidual(PetscDS prob, PetscInt f, 1504*30b9ff8bSMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 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[], 1507*30b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]), 1508*30b9ff8bSMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1509194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1510194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1511*30b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f1[])) 15122764a2aaSMatthew G. Knepley { 15132764a2aaSMatthew G. Knepley PetscErrorCode ierr; 15142764a2aaSMatthew G. Knepley 15152764a2aaSMatthew G. Knepley PetscFunctionBegin; 15162764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 15172764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 15182764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 15192764a2aaSMatthew G. Knepley if (f0) {PetscValidFunction(f0, 3); prob->fBd[f*2+0] = f0;} 15202764a2aaSMatthew G. Knepley if (f1) {PetscValidFunction(f1, 4); prob->fBd[f*2+1] = f1;} 15212764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 15222764a2aaSMatthew G. Knepley } 15232764a2aaSMatthew G. Knepley 15242764a2aaSMatthew G. Knepley #undef __FUNCT__ 15252764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdJacobian" 1526194d53e6SMatthew G. Knepley /*@C 1527194d53e6SMatthew G. Knepley PetscDSGetBdJacobian - Get the pointwise boundary Jacobian function for given test and basis field 1528194d53e6SMatthew G. Knepley 1529194d53e6SMatthew G. Knepley Not collective 1530194d53e6SMatthew G. Knepley 1531194d53e6SMatthew G. Knepley Input Parameters: 1532194d53e6SMatthew G. Knepley + prob - The PetscDS 1533194d53e6SMatthew G. Knepley . f - The test field number 1534194d53e6SMatthew G. Knepley - g - The field number 1535194d53e6SMatthew G. Knepley 1536194d53e6SMatthew G. Knepley Output Parameters: 1537194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 1538194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1539194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1540194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1541194d53e6SMatthew G. Knepley 1542194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1543194d53e6SMatthew G. Knepley 1544194d53e6SMatthew 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 1545194d53e6SMatthew G. Knepley 1546194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1547194d53e6SMatthew G. Knepley 1548*30b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1549194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1550194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1551*30b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 1552194d53e6SMatthew G. Knepley 1553194d53e6SMatthew G. Knepley + dim - the spatial dimension 1554194d53e6SMatthew G. Knepley . Nf - the number of fields 1555194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1556194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1557194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1558194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1559194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1560194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1561194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1562194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1563194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1564194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1565194d53e6SMatthew G. Knepley . t - current time 15662aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1567194d53e6SMatthew G. Knepley . x - coordinates of the current point 1568194d53e6SMatthew G. Knepley . n - normal at the current point 1569194d53e6SMatthew G. Knepley - g0 - output values at the current point 1570194d53e6SMatthew G. Knepley 1571194d53e6SMatthew G. Knepley Level: intermediate 1572194d53e6SMatthew G. Knepley 1573194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdJacobian() 1574194d53e6SMatthew G. Knepley @*/ 15752764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdJacobian(PetscDS prob, PetscInt f, PetscInt g, 1576*30b9ff8bSMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1577194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1578194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 15792aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g0[]), 1580*30b9ff8bSMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1581194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1582194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 15832aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g1[]), 1584*30b9ff8bSMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1585194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1586194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 15872aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g2[]), 1588*30b9ff8bSMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1589194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1590194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 15912aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g3[])) 15922764a2aaSMatthew G. Knepley { 15932764a2aaSMatthew G. Knepley PetscFunctionBegin; 15942764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 15952764a2aaSMatthew 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); 15962764a2aaSMatthew 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); 15972764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gBd[(f*prob->Nf + g)*4+0];} 15982764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gBd[(f*prob->Nf + g)*4+1];} 15992764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gBd[(f*prob->Nf + g)*4+2];} 16002764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gBd[(f*prob->Nf + g)*4+3];} 16012764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 16022764a2aaSMatthew G. Knepley } 16032764a2aaSMatthew G. Knepley 16042764a2aaSMatthew G. Knepley #undef __FUNCT__ 16052764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdJacobian" 1606194d53e6SMatthew G. Knepley /*@C 1607194d53e6SMatthew G. Knepley PetscDSSetBdJacobian - Set the pointwise boundary Jacobian function for given test and basis field 1608194d53e6SMatthew G. Knepley 1609194d53e6SMatthew G. Knepley Not collective 1610194d53e6SMatthew G. Knepley 1611194d53e6SMatthew G. Knepley Input Parameters: 1612194d53e6SMatthew G. Knepley + prob - The PetscDS 1613194d53e6SMatthew G. Knepley . f - The test field number 1614194d53e6SMatthew G. Knepley . g - The field number 1615194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 1616194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1617194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1618194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1619194d53e6SMatthew G. Knepley 1620194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1621194d53e6SMatthew G. Knepley 1622194d53e6SMatthew 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 1623194d53e6SMatthew G. Knepley 1624194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1625194d53e6SMatthew G. Knepley 1626*30b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1627194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1628194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1629*30b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 1630194d53e6SMatthew G. Knepley 1631194d53e6SMatthew G. Knepley + dim - the spatial dimension 1632194d53e6SMatthew G. Knepley . Nf - the number of fields 1633194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1634194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1635194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1636194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1637194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1638194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1639194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1640194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1641194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1642194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1643194d53e6SMatthew G. Knepley . t - current time 16442aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1645194d53e6SMatthew G. Knepley . x - coordinates of the current point 1646194d53e6SMatthew G. Knepley . n - normal at the current point 1647194d53e6SMatthew G. Knepley - g0 - output values at the current point 1648194d53e6SMatthew G. Knepley 1649194d53e6SMatthew G. Knepley Level: intermediate 1650194d53e6SMatthew G. Knepley 1651194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdJacobian() 1652194d53e6SMatthew G. Knepley @*/ 16532764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdJacobian(PetscDS prob, PetscInt f, PetscInt g, 1654*30b9ff8bSMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1655194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1656194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 16572aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g0[]), 1658*30b9ff8bSMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1659194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1660194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 16612aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g1[]), 1662*30b9ff8bSMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1663194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1664194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 16652aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g2[]), 1666*30b9ff8bSMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1667194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1668194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 16692aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g3[])) 16702764a2aaSMatthew G. Knepley { 16712764a2aaSMatthew G. Knepley PetscErrorCode ierr; 16722764a2aaSMatthew G. Knepley 16732764a2aaSMatthew G. Knepley PetscFunctionBegin; 16742764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 16752764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 16762764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 16772764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 16782764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 16792764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 16802764a2aaSMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 16812764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 16822764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+0] = g0; 16832764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+1] = g1; 16842764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+2] = g2; 16852764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+3] = g3; 16862764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 16872764a2aaSMatthew G. Knepley } 16882764a2aaSMatthew G. Knepley 16892764a2aaSMatthew G. Knepley #undef __FUNCT__ 16902764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetFieldOffset" 1691bc4ae4beSMatthew G. Knepley /*@ 1692bc4ae4beSMatthew G. Knepley PetscDSGetFieldOffset - Returns the offset of the given field in the full space basis 1693bc4ae4beSMatthew G. Knepley 1694bc4ae4beSMatthew G. Knepley Not collective 1695bc4ae4beSMatthew G. Knepley 1696bc4ae4beSMatthew G. Knepley Input Parameters: 1697bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 1698bc4ae4beSMatthew G. Knepley - f - The field number 1699bc4ae4beSMatthew G. Knepley 1700bc4ae4beSMatthew G. Knepley Output Parameter: 1701bc4ae4beSMatthew G. Knepley . off - The offset 1702bc4ae4beSMatthew G. Knepley 1703bc4ae4beSMatthew G. Knepley Level: beginner 1704bc4ae4beSMatthew G. Knepley 1705bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 1706bc4ae4beSMatthew G. Knepley @*/ 17072764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetFieldOffset(PetscDS prob, PetscInt f, PetscInt *off) 17082764a2aaSMatthew G. Knepley { 17092764a2aaSMatthew G. Knepley PetscInt g; 17102764a2aaSMatthew G. Knepley PetscErrorCode ierr; 17112764a2aaSMatthew G. Knepley 17122764a2aaSMatthew G. Knepley PetscFunctionBegin; 17132764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 17142764a2aaSMatthew G. Knepley PetscValidPointer(off, 3); 17152764a2aaSMatthew 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); 17162764a2aaSMatthew G. Knepley *off = 0; 17172764a2aaSMatthew G. Knepley for (g = 0; g < f; ++g) { 17182764a2aaSMatthew G. Knepley PetscFE fe = (PetscFE) prob->disc[g]; 17192764a2aaSMatthew G. Knepley PetscInt Nb, Nc; 17202764a2aaSMatthew G. Knepley 17212764a2aaSMatthew G. Knepley ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr); 17222764a2aaSMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 17232764a2aaSMatthew G. Knepley *off += Nb*Nc; 17242764a2aaSMatthew G. Knepley } 17252764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 17262764a2aaSMatthew G. Knepley } 17272764a2aaSMatthew G. Knepley 17282764a2aaSMatthew G. Knepley #undef __FUNCT__ 17292764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdFieldOffset" 1730bc4ae4beSMatthew G. Knepley /*@ 1731c3ac4435SMatthew G. Knepley PetscDSGetBdFieldOffset - Returns the offset of the given field in the full space boundary basis 1732bc4ae4beSMatthew G. Knepley 1733bc4ae4beSMatthew G. Knepley Not collective 1734bc4ae4beSMatthew G. Knepley 1735bc4ae4beSMatthew G. Knepley Input Parameters: 1736bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 1737bc4ae4beSMatthew G. Knepley - f - The field number 1738bc4ae4beSMatthew G. Knepley 1739bc4ae4beSMatthew G. Knepley Output Parameter: 1740bc4ae4beSMatthew G. Knepley . off - The boundary offset 1741bc4ae4beSMatthew G. Knepley 1742bc4ae4beSMatthew G. Knepley Level: beginner 1743bc4ae4beSMatthew G. Knepley 1744bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 1745bc4ae4beSMatthew G. Knepley @*/ 17462764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdFieldOffset(PetscDS prob, PetscInt f, PetscInt *off) 17472764a2aaSMatthew G. Knepley { 17482764a2aaSMatthew G. Knepley PetscInt g; 17492764a2aaSMatthew G. Knepley PetscErrorCode ierr; 17502764a2aaSMatthew G. Knepley 17512764a2aaSMatthew G. Knepley PetscFunctionBegin; 17522764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 17532764a2aaSMatthew G. Knepley PetscValidPointer(off, 3); 17542764a2aaSMatthew 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); 17552764a2aaSMatthew G. Knepley *off = 0; 17562764a2aaSMatthew G. Knepley for (g = 0; g < f; ++g) { 17572764a2aaSMatthew G. Knepley PetscFE fe = (PetscFE) prob->discBd[g]; 17582764a2aaSMatthew G. Knepley PetscInt Nb, Nc; 17592764a2aaSMatthew G. Knepley 17602764a2aaSMatthew G. Knepley ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr); 17612764a2aaSMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 17622764a2aaSMatthew G. Knepley *off += Nb*Nc; 17636ce16762SMatthew G. Knepley } 17646ce16762SMatthew G. Knepley PetscFunctionReturn(0); 17656ce16762SMatthew G. Knepley } 17666ce16762SMatthew G. Knepley 17676ce16762SMatthew G. Knepley #undef __FUNCT__ 17686ce16762SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentOffset" 17696ce16762SMatthew G. Knepley /*@ 17706ce16762SMatthew G. Knepley PetscDSGetComponentOffset - Returns the offset of the given field on an evaluation point 17716ce16762SMatthew G. Knepley 17726ce16762SMatthew G. Knepley Not collective 17736ce16762SMatthew G. Knepley 17746ce16762SMatthew G. Knepley Input Parameters: 17756ce16762SMatthew G. Knepley + prob - The PetscDS object 17766ce16762SMatthew G. Knepley - f - The field number 17776ce16762SMatthew G. Knepley 17786ce16762SMatthew G. Knepley Output Parameter: 17796ce16762SMatthew G. Knepley . off - The offset 17806ce16762SMatthew G. Knepley 17816ce16762SMatthew G. Knepley Level: beginner 17826ce16762SMatthew G. Knepley 17836ce16762SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 17846ce16762SMatthew G. Knepley @*/ 17856ce16762SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffset(PetscDS prob, PetscInt f, PetscInt *off) 17866ce16762SMatthew G. Knepley { 17876ce16762SMatthew G. Knepley PetscInt g; 17886ce16762SMatthew G. Knepley PetscErrorCode ierr; 17896ce16762SMatthew G. Knepley 17906ce16762SMatthew G. Knepley PetscFunctionBegin; 17916ce16762SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 17926ce16762SMatthew G. Knepley PetscValidPointer(off, 3); 17936ce16762SMatthew 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); 17946ce16762SMatthew G. Knepley *off = 0; 17956ce16762SMatthew G. Knepley for (g = 0; g < f; ++g) { 17966ce16762SMatthew G. Knepley PetscFE fe = (PetscFE) prob->disc[g]; 17976ce16762SMatthew G. Knepley PetscInt Nc; 17986ce16762SMatthew G. Knepley 17996ce16762SMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 18006ce16762SMatthew G. Knepley *off += Nc; 18012764a2aaSMatthew G. Knepley } 18022764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 18032764a2aaSMatthew G. Knepley } 18042764a2aaSMatthew G. Knepley 18052764a2aaSMatthew G. Knepley #undef __FUNCT__ 1806194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentOffsets" 1807194d53e6SMatthew G. Knepley /*@ 1808194d53e6SMatthew G. Knepley PetscDSGetComponentOffsets - Returns the offset of each field on an evaluation point 1809194d53e6SMatthew G. Knepley 1810194d53e6SMatthew G. Knepley Not collective 1811194d53e6SMatthew G. Knepley 1812194d53e6SMatthew G. Knepley Input Parameter: 1813194d53e6SMatthew G. Knepley . prob - The PetscDS object 1814194d53e6SMatthew G. Knepley 1815194d53e6SMatthew G. Knepley Output Parameter: 1816194d53e6SMatthew G. Knepley . offsets - The offsets 1817194d53e6SMatthew G. Knepley 1818194d53e6SMatthew G. Knepley Level: beginner 1819194d53e6SMatthew G. Knepley 1820194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 1821194d53e6SMatthew G. Knepley @*/ 1822194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffsets(PetscDS prob, PetscInt *offsets[]) 1823194d53e6SMatthew G. Knepley { 1824194d53e6SMatthew G. Knepley PetscFunctionBegin; 1825194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1826194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 1827194d53e6SMatthew G. Knepley *offsets = prob->off; 1828194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 1829194d53e6SMatthew G. Knepley } 1830194d53e6SMatthew G. Knepley 1831194d53e6SMatthew G. Knepley #undef __FUNCT__ 1832194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentDerivativeOffsets" 1833194d53e6SMatthew G. Knepley /*@ 1834194d53e6SMatthew G. Knepley PetscDSGetComponentDerivativeOffsets - Returns the offset of each field derivative on an evaluation point 1835194d53e6SMatthew G. Knepley 1836194d53e6SMatthew G. Knepley Not collective 1837194d53e6SMatthew G. Knepley 1838194d53e6SMatthew G. Knepley Input Parameter: 1839194d53e6SMatthew G. Knepley . prob - The PetscDS object 1840194d53e6SMatthew G. Knepley 1841194d53e6SMatthew G. Knepley Output Parameter: 1842194d53e6SMatthew G. Knepley . offsets - The offsets 1843194d53e6SMatthew G. Knepley 1844194d53e6SMatthew G. Knepley Level: beginner 1845194d53e6SMatthew G. Knepley 1846194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 1847194d53e6SMatthew G. Knepley @*/ 1848194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentDerivativeOffsets(PetscDS prob, PetscInt *offsets[]) 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 PetscFunctionBegin; 1877194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1878194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 1879194d53e6SMatthew G. Knepley *offsets = prob->offBd; 1880194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 1881194d53e6SMatthew G. Knepley } 1882194d53e6SMatthew G. Knepley 1883194d53e6SMatthew G. Knepley #undef __FUNCT__ 1884194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentBdDerivativeOffsets" 1885194d53e6SMatthew G. Knepley /*@ 1886194d53e6SMatthew G. Knepley PetscDSGetComponentBdDerivativeOffsets - Returns the offset of each field derivative on a boundary evaluation point 1887194d53e6SMatthew G. Knepley 1888194d53e6SMatthew G. Knepley Not collective 1889194d53e6SMatthew G. Knepley 1890194d53e6SMatthew G. Knepley Input Parameter: 1891194d53e6SMatthew G. Knepley . prob - The PetscDS object 1892194d53e6SMatthew G. Knepley 1893194d53e6SMatthew G. Knepley Output Parameter: 1894194d53e6SMatthew G. Knepley . offsets - The offsets 1895194d53e6SMatthew G. Knepley 1896194d53e6SMatthew G. Knepley Level: beginner 1897194d53e6SMatthew G. Knepley 1898194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 1899194d53e6SMatthew G. Knepley @*/ 1900194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentBdDerivativeOffsets(PetscDS prob, PetscInt *offsets[]) 1901194d53e6SMatthew G. Knepley { 1902194d53e6SMatthew G. Knepley PetscFunctionBegin; 1903194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1904194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 1905194d53e6SMatthew G. Knepley *offsets = prob->offDerBd; 1906194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 1907194d53e6SMatthew G. Knepley } 1908194d53e6SMatthew G. Knepley 1909194d53e6SMatthew G. Knepley #undef __FUNCT__ 19102764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTabulation" 191168c9edb9SMatthew G. Knepley /*@C 191268c9edb9SMatthew G. Knepley PetscDSGetTabulation - Return the basis tabulation at quadrature points for the volume discretization 191368c9edb9SMatthew G. Knepley 191468c9edb9SMatthew G. Knepley Not collective 191568c9edb9SMatthew G. Knepley 191668c9edb9SMatthew G. Knepley Input Parameter: 191768c9edb9SMatthew G. Knepley . prob - The PetscDS object 191868c9edb9SMatthew G. Knepley 191968c9edb9SMatthew G. Knepley Output Parameters: 192068c9edb9SMatthew G. Knepley + basis - The basis function tabulation at quadrature points 192168c9edb9SMatthew G. Knepley - basisDer - The basis function derivative tabulation at quadrature points 192268c9edb9SMatthew G. Knepley 192368c9edb9SMatthew G. Knepley Level: intermediate 192468c9edb9SMatthew G. Knepley 192568c9edb9SMatthew G. Knepley .seealso: PetscDSGetBdTabulation(), PetscDSCreate() 192668c9edb9SMatthew G. Knepley @*/ 19272764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTabulation(PetscDS prob, PetscReal ***basis, PetscReal ***basisDer) 19282764a2aaSMatthew G. Knepley { 19292764a2aaSMatthew G. Knepley PetscErrorCode ierr; 19302764a2aaSMatthew G. Knepley 19312764a2aaSMatthew G. Knepley PetscFunctionBegin; 19322764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 19332764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 19342764a2aaSMatthew G. Knepley if (basis) {PetscValidPointer(basis, 2); *basis = prob->basis;} 19352764a2aaSMatthew G. Knepley if (basisDer) {PetscValidPointer(basisDer, 3); *basisDer = prob->basisDer;} 19362764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 19372764a2aaSMatthew G. Knepley } 19382764a2aaSMatthew G. Knepley 19392764a2aaSMatthew G. Knepley #undef __FUNCT__ 19402764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdTabulation" 194168c9edb9SMatthew G. Knepley /*@C 194268c9edb9SMatthew G. Knepley PetscDSGetBdTabulation - Return the basis tabulation at quadrature points for the boundary discretization 194368c9edb9SMatthew G. Knepley 194468c9edb9SMatthew G. Knepley Not collective 194568c9edb9SMatthew G. Knepley 194668c9edb9SMatthew G. Knepley Input Parameter: 194768c9edb9SMatthew G. Knepley . prob - The PetscDS object 194868c9edb9SMatthew G. Knepley 194968c9edb9SMatthew G. Knepley Output Parameters: 195068c9edb9SMatthew G. Knepley + basis - The basis function tabulation at quadrature points 195168c9edb9SMatthew G. Knepley - basisDer - The basis function derivative tabulation at quadrature points 195268c9edb9SMatthew G. Knepley 195368c9edb9SMatthew G. Knepley Level: intermediate 195468c9edb9SMatthew G. Knepley 195568c9edb9SMatthew G. Knepley .seealso: PetscDSGetTabulation(), PetscDSCreate() 195668c9edb9SMatthew G. Knepley @*/ 19572764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdTabulation(PetscDS prob, PetscReal ***basis, PetscReal ***basisDer) 19582764a2aaSMatthew G. Knepley { 19592764a2aaSMatthew G. Knepley PetscErrorCode ierr; 19602764a2aaSMatthew G. Knepley 19612764a2aaSMatthew G. Knepley PetscFunctionBegin; 19622764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 19632764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 19642764a2aaSMatthew G. Knepley if (basis) {PetscValidPointer(basis, 2); *basis = prob->basisBd;} 19652764a2aaSMatthew G. Knepley if (basisDer) {PetscValidPointer(basisDer, 3); *basisDer = prob->basisDerBd;} 19662764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 19672764a2aaSMatthew G. Knepley } 19682764a2aaSMatthew G. Knepley 19692764a2aaSMatthew G. Knepley #undef __FUNCT__ 19702764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetEvaluationArrays" 19712764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetEvaluationArrays(PetscDS prob, PetscScalar **u, PetscScalar **u_t, PetscScalar **u_x) 19722764a2aaSMatthew G. Knepley { 19732764a2aaSMatthew G. Knepley PetscErrorCode ierr; 19742764a2aaSMatthew G. Knepley 19752764a2aaSMatthew G. Knepley PetscFunctionBegin; 19762764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 19772764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 19782764a2aaSMatthew G. Knepley if (u) {PetscValidPointer(u, 2); *u = prob->u;} 19792764a2aaSMatthew G. Knepley if (u_t) {PetscValidPointer(u_t, 3); *u_t = prob->u_t;} 19802764a2aaSMatthew G. Knepley if (u_x) {PetscValidPointer(u_x, 4); *u_x = prob->u_x;} 19812764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 19822764a2aaSMatthew G. Knepley } 19832764a2aaSMatthew G. Knepley 19842764a2aaSMatthew G. Knepley #undef __FUNCT__ 19852764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetWeakFormArrays" 19862764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetWeakFormArrays(PetscDS prob, PetscScalar **f0, PetscScalar **f1, PetscScalar **g0, PetscScalar **g1, PetscScalar **g2, PetscScalar **g3) 19872764a2aaSMatthew G. Knepley { 19882764a2aaSMatthew G. Knepley PetscErrorCode ierr; 19892764a2aaSMatthew G. Knepley 19902764a2aaSMatthew G. Knepley PetscFunctionBegin; 19912764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 19922764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 19932764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 2); *f0 = prob->f0;} 19942764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 3); *f1 = prob->f1;} 19952764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g0;} 19962764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g1;} 19972764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g2;} 19982764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g3;} 19992764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 20002764a2aaSMatthew G. Knepley } 20012764a2aaSMatthew G. Knepley 20022764a2aaSMatthew G. Knepley #undef __FUNCT__ 20032764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetRefCoordArrays" 20042764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetRefCoordArrays(PetscDS prob, PetscReal **x, PetscScalar **refSpaceDer) 20052764a2aaSMatthew G. Knepley { 20062764a2aaSMatthew G. Knepley PetscErrorCode ierr; 20072764a2aaSMatthew G. Knepley 20082764a2aaSMatthew G. Knepley PetscFunctionBegin; 20092764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 20102764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 20112764a2aaSMatthew G. Knepley if (x) {PetscValidPointer(x, 2); *x = prob->x;} 20122764a2aaSMatthew G. Knepley if (refSpaceDer) {PetscValidPointer(refSpaceDer, 3); *refSpaceDer = prob->refSpaceDer;} 20132764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 20142764a2aaSMatthew G. Knepley } 20152764a2aaSMatthew G. Knepley 20162764a2aaSMatthew G. Knepley #undef __FUNCT__ 20172764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroy_Basic" 2018bc4ae4beSMatthew G. Knepley static PetscErrorCode PetscDSDestroy_Basic(PetscDS prob) 20192764a2aaSMatthew G. Knepley { 20202764a2aaSMatthew G. Knepley PetscFunctionBegin; 20212764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 20222764a2aaSMatthew G. Knepley } 20232764a2aaSMatthew G. Knepley 20242764a2aaSMatthew G. Knepley #undef __FUNCT__ 20252764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSInitialize_Basic" 2026bc4ae4beSMatthew G. Knepley static PetscErrorCode PetscDSInitialize_Basic(PetscDS prob) 20272764a2aaSMatthew G. Knepley { 20282764a2aaSMatthew G. Knepley PetscFunctionBegin; 20292764a2aaSMatthew G. Knepley prob->ops->setfromoptions = NULL; 20302764a2aaSMatthew G. Knepley prob->ops->setup = NULL; 20312764a2aaSMatthew G. Knepley prob->ops->view = NULL; 20322764a2aaSMatthew G. Knepley prob->ops->destroy = PetscDSDestroy_Basic; 20332764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 20342764a2aaSMatthew G. Knepley } 20352764a2aaSMatthew G. Knepley 20362764a2aaSMatthew G. Knepley /*MC 20372764a2aaSMatthew G. Knepley PETSCDSBASIC = "basic" - A discrete system with pointwise residual and boundary residual functions 20382764a2aaSMatthew G. Knepley 20392764a2aaSMatthew G. Knepley Level: intermediate 20402764a2aaSMatthew G. Knepley 20412764a2aaSMatthew G. Knepley .seealso: PetscDSType, PetscDSCreate(), PetscDSSetType() 20422764a2aaSMatthew G. Knepley M*/ 20432764a2aaSMatthew G. Knepley 20442764a2aaSMatthew G. Knepley #undef __FUNCT__ 20452764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSCreate_Basic" 20462764a2aaSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscDSCreate_Basic(PetscDS prob) 20472764a2aaSMatthew G. Knepley { 20482764a2aaSMatthew G. Knepley PetscDS_Basic *b; 20492764a2aaSMatthew G. Knepley PetscErrorCode ierr; 20502764a2aaSMatthew G. Knepley 20512764a2aaSMatthew G. Knepley PetscFunctionBegin; 20522764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCSPACE_CLASSID, 1); 20532764a2aaSMatthew G. Knepley ierr = PetscNewLog(prob, &b);CHKERRQ(ierr); 20542764a2aaSMatthew G. Knepley prob->data = b; 20552764a2aaSMatthew G. Knepley 20562764a2aaSMatthew G. Knepley ierr = PetscDSInitialize_Basic(prob);CHKERRQ(ierr); 20572764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 20582764a2aaSMatthew G. Knepley } 2059