1af0996ceSBarry Smith #include <petsc/private/petscdsimpl.h> /*I "petscds.h" I*/ 22764a2aaSMatthew G. Knepley 32764a2aaSMatthew G. Knepley PetscClassId PETSCDS_CLASSID = 0; 42764a2aaSMatthew G. Knepley 52764a2aaSMatthew G. Knepley PetscFunctionList PetscDSList = NULL; 62764a2aaSMatthew G. Knepley PetscBool PetscDSRegisterAllCalled = PETSC_FALSE; 72764a2aaSMatthew G. Knepley 82764a2aaSMatthew G. Knepley #undef __FUNCT__ 92764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSRegister" 102764a2aaSMatthew G. Knepley /*@C 112764a2aaSMatthew G. Knepley PetscDSRegister - Adds a new PetscDS implementation 122764a2aaSMatthew G. Knepley 132764a2aaSMatthew G. Knepley Not Collective 142764a2aaSMatthew G. Knepley 152764a2aaSMatthew G. Knepley Input Parameters: 162764a2aaSMatthew G. Knepley + name - The name of a new user-defined creation routine 172764a2aaSMatthew G. Knepley - create_func - The creation routine itself 182764a2aaSMatthew G. Knepley 192764a2aaSMatthew G. Knepley Notes: 202764a2aaSMatthew G. Knepley PetscDSRegister() may be called multiple times to add several user-defined PetscDSs 212764a2aaSMatthew G. Knepley 222764a2aaSMatthew G. Knepley Sample usage: 232764a2aaSMatthew G. Knepley .vb 242764a2aaSMatthew G. Knepley PetscDSRegister("my_ds", MyPetscDSCreate); 252764a2aaSMatthew G. Knepley .ve 262764a2aaSMatthew G. Knepley 272764a2aaSMatthew G. Knepley Then, your PetscDS type can be chosen with the procedural interface via 282764a2aaSMatthew G. Knepley .vb 292764a2aaSMatthew G. Knepley PetscDSCreate(MPI_Comm, PetscDS *); 302764a2aaSMatthew G. Knepley PetscDSSetType(PetscDS, "my_ds"); 312764a2aaSMatthew G. Knepley .ve 322764a2aaSMatthew G. Knepley or at runtime via the option 332764a2aaSMatthew G. Knepley .vb 342764a2aaSMatthew G. Knepley -petscds_type my_ds 352764a2aaSMatthew G. Knepley .ve 362764a2aaSMatthew G. Knepley 372764a2aaSMatthew G. Knepley Level: advanced 382764a2aaSMatthew G. Knepley 392764a2aaSMatthew G. Knepley .keywords: PetscDS, register 402764a2aaSMatthew G. Knepley .seealso: PetscDSRegisterAll(), PetscDSRegisterDestroy() 412764a2aaSMatthew G. Knepley 422764a2aaSMatthew G. Knepley @*/ 432764a2aaSMatthew G. Knepley PetscErrorCode PetscDSRegister(const char sname[], PetscErrorCode (*function)(PetscDS)) 442764a2aaSMatthew G. Knepley { 452764a2aaSMatthew G. Knepley PetscErrorCode ierr; 462764a2aaSMatthew G. Knepley 472764a2aaSMatthew G. Knepley PetscFunctionBegin; 482764a2aaSMatthew G. Knepley ierr = PetscFunctionListAdd(&PetscDSList, sname, function);CHKERRQ(ierr); 492764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 502764a2aaSMatthew G. Knepley } 512764a2aaSMatthew G. Knepley 522764a2aaSMatthew G. Knepley #undef __FUNCT__ 532764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetType" 542764a2aaSMatthew G. Knepley /*@C 552764a2aaSMatthew G. Knepley PetscDSSetType - Builds a particular PetscDS 562764a2aaSMatthew G. Knepley 572764a2aaSMatthew G. Knepley Collective on PetscDS 582764a2aaSMatthew G. Knepley 592764a2aaSMatthew G. Knepley Input Parameters: 602764a2aaSMatthew G. Knepley + prob - The PetscDS object 612764a2aaSMatthew G. Knepley - name - The kind of system 622764a2aaSMatthew G. Knepley 632764a2aaSMatthew G. Knepley Options Database Key: 642764a2aaSMatthew G. Knepley . -petscds_type <type> - Sets the PetscDS type; use -help for a list of available types 652764a2aaSMatthew G. Knepley 662764a2aaSMatthew G. Knepley Level: intermediate 672764a2aaSMatthew G. Knepley 682764a2aaSMatthew G. Knepley .keywords: PetscDS, set, type 692764a2aaSMatthew G. Knepley .seealso: PetscDSGetType(), PetscDSCreate() 702764a2aaSMatthew G. Knepley @*/ 712764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetType(PetscDS prob, PetscDSType name) 722764a2aaSMatthew G. Knepley { 732764a2aaSMatthew G. Knepley PetscErrorCode (*r)(PetscDS); 742764a2aaSMatthew G. Knepley PetscBool match; 752764a2aaSMatthew G. Knepley PetscErrorCode ierr; 762764a2aaSMatthew G. Knepley 772764a2aaSMatthew G. Knepley PetscFunctionBegin; 782764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 792764a2aaSMatthew G. Knepley ierr = PetscObjectTypeCompare((PetscObject) prob, name, &match);CHKERRQ(ierr); 802764a2aaSMatthew G. Knepley if (match) PetscFunctionReturn(0); 812764a2aaSMatthew G. Knepley 820f51fdf8SToby Isaac ierr = PetscDSRegisterAll();CHKERRQ(ierr); 832764a2aaSMatthew G. Knepley ierr = PetscFunctionListFind(PetscDSList, name, &r);CHKERRQ(ierr); 842764a2aaSMatthew G. Knepley if (!r) SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_UNKNOWN_TYPE, "Unknown PetscDS type: %s", name); 852764a2aaSMatthew G. Knepley 862764a2aaSMatthew G. Knepley if (prob->ops->destroy) { 872764a2aaSMatthew G. Knepley ierr = (*prob->ops->destroy)(prob);CHKERRQ(ierr); 882764a2aaSMatthew G. Knepley prob->ops->destroy = NULL; 892764a2aaSMatthew G. Knepley } 902764a2aaSMatthew G. Knepley ierr = (*r)(prob);CHKERRQ(ierr); 912764a2aaSMatthew G. Knepley ierr = PetscObjectChangeTypeName((PetscObject) prob, name);CHKERRQ(ierr); 922764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 932764a2aaSMatthew G. Knepley } 942764a2aaSMatthew G. Knepley 952764a2aaSMatthew G. Knepley #undef __FUNCT__ 962764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetType" 972764a2aaSMatthew G. Knepley /*@C 982764a2aaSMatthew G. Knepley PetscDSGetType - Gets the PetscDS type name (as a string) from the object. 992764a2aaSMatthew G. Knepley 1002764a2aaSMatthew G. Knepley Not Collective 1012764a2aaSMatthew G. Knepley 1022764a2aaSMatthew G. Knepley Input Parameter: 1032764a2aaSMatthew G. Knepley . prob - The PetscDS 1042764a2aaSMatthew G. Knepley 1052764a2aaSMatthew G. Knepley Output Parameter: 1062764a2aaSMatthew G. Knepley . name - The PetscDS type name 1072764a2aaSMatthew G. Knepley 1082764a2aaSMatthew G. Knepley Level: intermediate 1092764a2aaSMatthew G. Knepley 1102764a2aaSMatthew G. Knepley .keywords: PetscDS, get, type, name 1112764a2aaSMatthew G. Knepley .seealso: PetscDSSetType(), PetscDSCreate() 1122764a2aaSMatthew G. Knepley @*/ 1132764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetType(PetscDS prob, PetscDSType *name) 1142764a2aaSMatthew G. Knepley { 1152764a2aaSMatthew G. Knepley PetscErrorCode ierr; 1162764a2aaSMatthew G. Knepley 1172764a2aaSMatthew G. Knepley PetscFunctionBegin; 1182764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 119c959eef4SJed Brown PetscValidPointer(name, 2); 1200f51fdf8SToby Isaac ierr = PetscDSRegisterAll();CHKERRQ(ierr); 1212764a2aaSMatthew G. Knepley *name = ((PetscObject) prob)->type_name; 1222764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 1232764a2aaSMatthew G. Knepley } 1242764a2aaSMatthew G. Knepley 1252764a2aaSMatthew G. Knepley #undef __FUNCT__ 1267d8a60eaSMatthew G. Knepley #define __FUNCT__ "PetscDSView_Ascii" 1277d8a60eaSMatthew G. Knepley static PetscErrorCode PetscDSView_Ascii(PetscDS prob, PetscViewer viewer) 1287d8a60eaSMatthew G. Knepley { 1297d8a60eaSMatthew G. Knepley PetscViewerFormat format; 1307d8a60eaSMatthew G. Knepley PetscInt f; 1317d8a60eaSMatthew G. Knepley PetscErrorCode ierr; 1327d8a60eaSMatthew G. Knepley 1337d8a60eaSMatthew G. Knepley PetscFunctionBegin; 1347d8a60eaSMatthew G. Knepley ierr = PetscViewerGetFormat(viewer, &format);CHKERRQ(ierr); 1357d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "Discrete System with %d fields\n", prob->Nf);CHKERRQ(ierr); 1367d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); 1377d8a60eaSMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 1387d8a60eaSMatthew G. Knepley PetscObject obj; 1397d8a60eaSMatthew G. Knepley PetscClassId id; 1407d8a60eaSMatthew G. Knepley const char *name; 1417d8a60eaSMatthew G. Knepley PetscInt Nc; 1427d8a60eaSMatthew G. Knepley 1437d8a60eaSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr); 1447d8a60eaSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 1457d8a60eaSMatthew G. Knepley ierr = PetscObjectGetName(obj, &name);CHKERRQ(ierr); 1467d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "Field %s", name ? name : "<unknown>");CHKERRQ(ierr); 1477d8a60eaSMatthew G. Knepley if (id == PETSCFE_CLASSID) { 1487d8a60eaSMatthew G. Knepley ierr = PetscFEGetNumComponents((PetscFE) obj, &Nc);CHKERRQ(ierr); 1497d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, " FEM");CHKERRQ(ierr); 1507d8a60eaSMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 1517d8a60eaSMatthew G. Knepley ierr = PetscFVGetNumComponents((PetscFV) obj, &Nc);CHKERRQ(ierr); 1527d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, " FVM");CHKERRQ(ierr); 1537d8a60eaSMatthew G. Knepley } 1547d8a60eaSMatthew G. Knepley else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", f); 1557d8a60eaSMatthew G. Knepley if (Nc > 1) {ierr = PetscViewerASCIIPrintf(viewer, "%d components", Nc);CHKERRQ(ierr);} 1567d8a60eaSMatthew G. Knepley else {ierr = PetscViewerASCIIPrintf(viewer, "%d component ", Nc);CHKERRQ(ierr);} 157249df284SMatthew G. Knepley if (prob->implicit[f]) {ierr = PetscViewerASCIIPrintf(viewer, " (implicit)");CHKERRQ(ierr);} 158249df284SMatthew G. Knepley else {ierr = PetscViewerASCIIPrintf(viewer, " (explicit)");CHKERRQ(ierr);} 159a6cbbb48SMatthew G. Knepley if (prob->adjacency[f*2+0]) { 160a6cbbb48SMatthew G. Knepley if (prob->adjacency[f*2+1]) {ierr = PetscViewerASCIIPrintf(viewer, " (adj FVM++)");CHKERRQ(ierr);} 161a6cbbb48SMatthew G. Knepley else {ierr = PetscViewerASCIIPrintf(viewer, " (adj FVM)");CHKERRQ(ierr);} 162a6cbbb48SMatthew G. Knepley } else { 163a6cbbb48SMatthew G. Knepley if (prob->adjacency[f*2+1]) {ierr = PetscViewerASCIIPrintf(viewer, " (adj FEM)");CHKERRQ(ierr);} 164a6cbbb48SMatthew G. Knepley else {ierr = PetscViewerASCIIPrintf(viewer, " (adj FUNKY)");CHKERRQ(ierr);} 165a6cbbb48SMatthew G. Knepley } 1667d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPrintf(viewer, "\n");CHKERRQ(ierr); 1677d8a60eaSMatthew G. Knepley if (format == PETSC_VIEWER_ASCII_INFO_DETAIL) { 1687d8a60eaSMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEView((PetscFE) obj, viewer);CHKERRQ(ierr);} 1697d8a60eaSMatthew G. Knepley else if (id == PETSCFV_CLASSID) {ierr = PetscFVView((PetscFV) obj, viewer);CHKERRQ(ierr);} 1707d8a60eaSMatthew G. Knepley } 1717d8a60eaSMatthew G. Knepley } 1727d8a60eaSMatthew G. Knepley ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); 1737d8a60eaSMatthew G. Knepley PetscFunctionReturn(0); 1747d8a60eaSMatthew G. Knepley } 1757d8a60eaSMatthew G. Knepley 1767d8a60eaSMatthew G. Knepley #undef __FUNCT__ 1772764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSView" 1782764a2aaSMatthew G. Knepley /*@C 1792764a2aaSMatthew G. Knepley PetscDSView - Views a PetscDS 1802764a2aaSMatthew G. Knepley 1812764a2aaSMatthew G. Knepley Collective on PetscDS 1822764a2aaSMatthew G. Knepley 1832764a2aaSMatthew G. Knepley Input Parameter: 1842764a2aaSMatthew G. Knepley + prob - the PetscDS object to view 1852764a2aaSMatthew G. Knepley - v - the viewer 1862764a2aaSMatthew G. Knepley 1872764a2aaSMatthew G. Knepley Level: developer 1882764a2aaSMatthew G. Knepley 1892764a2aaSMatthew G. Knepley .seealso PetscDSDestroy() 1902764a2aaSMatthew G. Knepley @*/ 1912764a2aaSMatthew G. Knepley PetscErrorCode PetscDSView(PetscDS prob, PetscViewer v) 1922764a2aaSMatthew G. Knepley { 1937d8a60eaSMatthew G. Knepley PetscBool iascii; 1942764a2aaSMatthew G. Knepley PetscErrorCode ierr; 1952764a2aaSMatthew G. Knepley 1962764a2aaSMatthew G. Knepley PetscFunctionBegin; 1972764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1982764a2aaSMatthew G. Knepley if (!v) {ierr = PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject) prob), &v);CHKERRQ(ierr);} 1997d8a60eaSMatthew G. Knepley else {PetscValidHeaderSpecific(v, PETSC_VIEWER_CLASSID, 2);} 2007d8a60eaSMatthew G. Knepley ierr = PetscObjectTypeCompare((PetscObject) v, PETSCVIEWERASCII, &iascii);CHKERRQ(ierr); 2017d8a60eaSMatthew G. Knepley if (iascii) {ierr = PetscDSView_Ascii(prob, v);CHKERRQ(ierr);} 2022764a2aaSMatthew G. Knepley if (prob->ops->view) {ierr = (*prob->ops->view)(prob, v);CHKERRQ(ierr);} 2032764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 2042764a2aaSMatthew G. Knepley } 2052764a2aaSMatthew G. Knepley 2062764a2aaSMatthew G. Knepley #undef __FUNCT__ 2072764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetFromOptions" 2082764a2aaSMatthew G. Knepley /*@ 2092764a2aaSMatthew G. Knepley PetscDSSetFromOptions - sets parameters in a PetscDS from the options database 2102764a2aaSMatthew G. Knepley 2112764a2aaSMatthew G. Knepley Collective on PetscDS 2122764a2aaSMatthew G. Knepley 2132764a2aaSMatthew G. Knepley Input Parameter: 2142764a2aaSMatthew G. Knepley . prob - the PetscDS object to set options for 2152764a2aaSMatthew G. Knepley 2162764a2aaSMatthew G. Knepley Options Database: 2172764a2aaSMatthew G. Knepley 2182764a2aaSMatthew G. Knepley Level: developer 2192764a2aaSMatthew G. Knepley 2202764a2aaSMatthew G. Knepley .seealso PetscDSView() 2212764a2aaSMatthew G. Knepley @*/ 2222764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetFromOptions(PetscDS prob) 2232764a2aaSMatthew G. Knepley { 2242764a2aaSMatthew G. Knepley const char *defaultType; 2252764a2aaSMatthew G. Knepley char name[256]; 2262764a2aaSMatthew G. Knepley PetscBool flg; 2272764a2aaSMatthew G. Knepley PetscErrorCode ierr; 2282764a2aaSMatthew G. Knepley 2292764a2aaSMatthew G. Knepley PetscFunctionBegin; 2302764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2312764a2aaSMatthew G. Knepley if (!((PetscObject) prob)->type_name) { 2322764a2aaSMatthew G. Knepley defaultType = PETSCDSBASIC; 2332764a2aaSMatthew G. Knepley } else { 2342764a2aaSMatthew G. Knepley defaultType = ((PetscObject) prob)->type_name; 2352764a2aaSMatthew G. Knepley } 2360f51fdf8SToby Isaac ierr = PetscDSRegisterAll();CHKERRQ(ierr); 2372764a2aaSMatthew G. Knepley 2382764a2aaSMatthew G. Knepley ierr = PetscObjectOptionsBegin((PetscObject) prob);CHKERRQ(ierr); 2392764a2aaSMatthew G. Knepley ierr = PetscOptionsFList("-petscds_type", "Discrete System", "PetscDSSetType", PetscDSList, defaultType, name, 256, &flg);CHKERRQ(ierr); 2402764a2aaSMatthew G. Knepley if (flg) { 2412764a2aaSMatthew G. Knepley ierr = PetscDSSetType(prob, name);CHKERRQ(ierr); 2422764a2aaSMatthew G. Knepley } else if (!((PetscObject) prob)->type_name) { 2432764a2aaSMatthew G. Knepley ierr = PetscDSSetType(prob, defaultType);CHKERRQ(ierr); 2442764a2aaSMatthew G. Knepley } 2452764a2aaSMatthew G. Knepley if (prob->ops->setfromoptions) {ierr = (*prob->ops->setfromoptions)(prob);CHKERRQ(ierr);} 2462764a2aaSMatthew G. Knepley /* process any options handlers added with PetscObjectAddOptionsHandler() */ 2470633abcbSJed Brown ierr = PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject) prob);CHKERRQ(ierr); 2482764a2aaSMatthew G. Knepley ierr = PetscOptionsEnd();CHKERRQ(ierr); 2492764a2aaSMatthew G. Knepley ierr = PetscDSViewFromOptions(prob, NULL, "-petscds_view");CHKERRQ(ierr); 2502764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 2512764a2aaSMatthew G. Knepley } 2522764a2aaSMatthew G. Knepley 2532764a2aaSMatthew G. Knepley #undef __FUNCT__ 2542764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetUp" 2552764a2aaSMatthew G. Knepley /*@C 2562764a2aaSMatthew G. Knepley PetscDSSetUp - Construct data structures for the PetscDS 2572764a2aaSMatthew G. Knepley 2582764a2aaSMatthew G. Knepley Collective on PetscDS 2592764a2aaSMatthew G. Knepley 2602764a2aaSMatthew G. Knepley Input Parameter: 2612764a2aaSMatthew G. Knepley . prob - the PetscDS object to setup 2622764a2aaSMatthew G. Knepley 2632764a2aaSMatthew G. Knepley Level: developer 2642764a2aaSMatthew G. Knepley 2652764a2aaSMatthew G. Knepley .seealso PetscDSView(), PetscDSDestroy() 2662764a2aaSMatthew G. Knepley @*/ 2672764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetUp(PetscDS prob) 2682764a2aaSMatthew G. Knepley { 2692764a2aaSMatthew G. Knepley const PetscInt Nf = prob->Nf; 2702764a2aaSMatthew G. Knepley PetscInt dim, work, NcMax = 0, NqMax = 0, f; 2712764a2aaSMatthew G. Knepley PetscErrorCode ierr; 2722764a2aaSMatthew G. Knepley 2732764a2aaSMatthew G. Knepley PetscFunctionBegin; 2742764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2752764a2aaSMatthew G. Knepley if (prob->setup) PetscFunctionReturn(0); 2762764a2aaSMatthew G. Knepley /* Calculate sizes */ 2772764a2aaSMatthew G. Knepley ierr = PetscDSGetSpatialDimension(prob, &dim);CHKERRQ(ierr); 2782764a2aaSMatthew G. Knepley prob->totDim = prob->totDimBd = prob->totComp = 0; 279194d53e6SMatthew G. Knepley ierr = PetscCalloc4(Nf+1,&prob->off,Nf+1,&prob->offDer,Nf+1,&prob->offBd,Nf+1,&prob->offDerBd);CHKERRQ(ierr); 2802764a2aaSMatthew G. Knepley ierr = PetscMalloc4(Nf,&prob->basis,Nf,&prob->basisDer,Nf,&prob->basisBd,Nf,&prob->basisDerBd);CHKERRQ(ierr); 2812764a2aaSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 2822764a2aaSMatthew G. Knepley PetscFE feBd = (PetscFE) prob->discBd[f]; 2839de99aefSMatthew G. Knepley PetscObject obj; 2849de99aefSMatthew G. Knepley PetscClassId id; 2852764a2aaSMatthew G. Knepley PetscQuadrature q; 2869de99aefSMatthew G. Knepley PetscInt Nq = 0, Nb, Nc; 2872764a2aaSMatthew G. Knepley 2889de99aefSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr); 2899de99aefSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 2909de99aefSMatthew G. Knepley if (id == PETSCFE_CLASSID) { 2919de99aefSMatthew G. Knepley PetscFE fe = (PetscFE) obj; 2929de99aefSMatthew G. Knepley 2932764a2aaSMatthew G. Knepley ierr = PetscFEGetQuadrature(fe, &q);CHKERRQ(ierr); 2942764a2aaSMatthew G. Knepley ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr); 2952764a2aaSMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 2962764a2aaSMatthew G. Knepley ierr = PetscFEGetDefaultTabulation(fe, &prob->basis[f], &prob->basisDer[f], NULL);CHKERRQ(ierr); 2979de99aefSMatthew G. Knepley } else if (id == PETSCFV_CLASSID) { 2989de99aefSMatthew G. Knepley PetscFV fv = (PetscFV) obj; 2999de99aefSMatthew G. Knepley 3009de99aefSMatthew G. Knepley ierr = PetscFVGetQuadrature(fv, &q);CHKERRQ(ierr); 3019de99aefSMatthew G. Knepley Nb = 1; 3029de99aefSMatthew G. Knepley ierr = PetscFVGetNumComponents(fv, &Nc);CHKERRQ(ierr); 3036c1a3d01SMatthew G. Knepley ierr = PetscFVGetDefaultTabulation(fv, &prob->basis[f], &prob->basisDer[f], NULL);CHKERRQ(ierr); 304abac5ca0SMatthew G. Knepley } else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", f); 305194d53e6SMatthew G. Knepley prob->off[f+1] = Nc + prob->off[f]; 306194d53e6SMatthew G. Knepley prob->offDer[f+1] = Nc*dim + prob->offDer[f]; 3079de99aefSMatthew G. Knepley if (q) {ierr = PetscQuadratureGetData(q, NULL, &Nq, NULL, NULL);CHKERRQ(ierr);} 3082764a2aaSMatthew G. Knepley NqMax = PetscMax(NqMax, Nq); 3092764a2aaSMatthew G. Knepley NcMax = PetscMax(NcMax, Nc); 3102764a2aaSMatthew G. Knepley prob->totDim += Nb*Nc; 3112764a2aaSMatthew G. Knepley prob->totComp += Nc; 3122764a2aaSMatthew G. Knepley if (feBd) { 3132764a2aaSMatthew G. Knepley ierr = PetscFEGetDimension(feBd, &Nb);CHKERRQ(ierr); 3142764a2aaSMatthew G. Knepley ierr = PetscFEGetNumComponents(feBd, &Nc);CHKERRQ(ierr); 3152764a2aaSMatthew G. Knepley ierr = PetscFEGetDefaultTabulation(feBd, &prob->basisBd[f], &prob->basisDerBd[f], NULL);CHKERRQ(ierr); 3162764a2aaSMatthew G. Knepley prob->totDimBd += Nb*Nc; 317194d53e6SMatthew G. Knepley prob->offBd[f+1] = Nc + prob->offBd[f]; 318194d53e6SMatthew G. Knepley prob->offDerBd[f+1] = Nc*dim + prob->offDerBd[f]; 3192764a2aaSMatthew G. Knepley } 3202764a2aaSMatthew G. Knepley } 3212764a2aaSMatthew G. Knepley work = PetscMax(prob->totComp*dim, PetscSqr(NcMax*dim)); 3222764a2aaSMatthew G. Knepley /* Allocate works space */ 3232764a2aaSMatthew G. Knepley ierr = PetscMalloc5(prob->totComp,&prob->u,prob->totComp,&prob->u_t,prob->totComp*dim,&prob->u_x,dim,&prob->x,work,&prob->refSpaceDer);CHKERRQ(ierr); 3242764a2aaSMatthew G. Knepley ierr = PetscMalloc6(NqMax*NcMax,&prob->f0,NqMax*NcMax*dim,&prob->f1,NqMax*NcMax*NcMax,&prob->g0,NqMax*NcMax*NcMax*dim,&prob->g1,NqMax*NcMax*NcMax*dim,&prob->g2,NqMax*NcMax*NcMax*dim*dim,&prob->g3);CHKERRQ(ierr); 3252764a2aaSMatthew G. Knepley if (prob->ops->setup) {ierr = (*prob->ops->setup)(prob);CHKERRQ(ierr);} 3262764a2aaSMatthew G. Knepley prob->setup = PETSC_TRUE; 3272764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 3282764a2aaSMatthew G. Knepley } 3292764a2aaSMatthew G. Knepley 3302764a2aaSMatthew G. Knepley #undef __FUNCT__ 3312764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroyStructs_Static" 3322764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSDestroyStructs_Static(PetscDS prob) 3332764a2aaSMatthew G. Knepley { 3342764a2aaSMatthew G. Knepley PetscErrorCode ierr; 3352764a2aaSMatthew G. Knepley 3362764a2aaSMatthew G. Knepley PetscFunctionBegin; 337194d53e6SMatthew G. Knepley ierr = PetscFree4(prob->off,prob->offDer,prob->offBd,prob->offDerBd);CHKERRQ(ierr); 3382764a2aaSMatthew G. Knepley ierr = PetscFree4(prob->basis,prob->basisDer,prob->basisBd,prob->basisDerBd);CHKERRQ(ierr); 3392764a2aaSMatthew G. Knepley ierr = PetscFree5(prob->u,prob->u_t,prob->u_x,prob->x,prob->refSpaceDer);CHKERRQ(ierr); 3402764a2aaSMatthew G. Knepley ierr = PetscFree6(prob->f0,prob->f1,prob->g0,prob->g1,prob->g2,prob->g3);CHKERRQ(ierr); 3412764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 3422764a2aaSMatthew G. Knepley } 3432764a2aaSMatthew G. Knepley 3442764a2aaSMatthew G. Knepley #undef __FUNCT__ 3452764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSEnlarge_Static" 3462764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSEnlarge_Static(PetscDS prob, PetscInt NfNew) 3472764a2aaSMatthew G. Knepley { 3482764a2aaSMatthew G. Knepley PetscObject *tmpd, *tmpdbd; 349a6cbbb48SMatthew G. Knepley PetscBool *tmpi, *tmpa; 3502aa1fc23SMatthew G. Knepley PetscPointFunc *tmpobj, *tmpf; 351*b7e05686SMatthew G. Knepley PetscPointJac *tmpg, *tmpgp, *tmpgt; 3522aa1fc23SMatthew G. Knepley PetscBdPointFunc *tmpfbd; 3532aa1fc23SMatthew G. Knepley PetscBdPointJac *tmpgbd; 354194d53e6SMatthew G. Knepley PetscRiemannFunc *tmpr; 3550c2f2876SMatthew G. Knepley void **tmpctx; 356a6cbbb48SMatthew G. Knepley PetscInt Nf = prob->Nf, f, i; 3572764a2aaSMatthew G. Knepley PetscErrorCode ierr; 3582764a2aaSMatthew G. Knepley 3592764a2aaSMatthew G. Knepley PetscFunctionBegin; 3602764a2aaSMatthew G. Knepley if (Nf >= NfNew) PetscFunctionReturn(0); 3612764a2aaSMatthew G. Knepley prob->setup = PETSC_FALSE; 3622764a2aaSMatthew G. Knepley ierr = PetscDSDestroyStructs_Static(prob);CHKERRQ(ierr); 363a6cbbb48SMatthew G. Knepley ierr = PetscMalloc4(NfNew, &tmpd, NfNew, &tmpdbd, NfNew, &tmpi, NfNew*2, &tmpa);CHKERRQ(ierr); 364a6cbbb48SMatthew G. Knepley for (f = 0; f < Nf; ++f) {tmpd[f] = prob->disc[f]; tmpdbd[f] = prob->discBd[f]; tmpi[f] = prob->implicit[f]; for (i = 0; i < 2; ++i) tmpa[f*2+i] = prob->adjacency[f*2+i];} 365a6cbbb48SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) {ierr = PetscContainerCreate(PetscObjectComm((PetscObject) prob), (PetscContainer *) &tmpd[f]);CHKERRQ(ierr); 366a6cbbb48SMatthew G. Knepley tmpdbd[f] = NULL; tmpi[f] = PETSC_TRUE; tmpa[f*2+0] = PETSC_FALSE; tmpa[f*2+1] = PETSC_TRUE;} 367a6cbbb48SMatthew G. Knepley ierr = PetscFree4(prob->disc, prob->discBd, prob->implicit, prob->adjacency);CHKERRQ(ierr); 3682764a2aaSMatthew G. Knepley prob->Nf = NfNew; 3692764a2aaSMatthew G. Knepley prob->disc = tmpd; 370a6cbbb48SMatthew G. Knepley prob->discBd = tmpdbd; 371249df284SMatthew G. Knepley prob->implicit = tmpi; 372a6cbbb48SMatthew G. Knepley prob->adjacency = tmpa; 373*b7e05686SMatthew G. Knepley ierr = PetscCalloc7(NfNew, &tmpobj, NfNew*2, &tmpf, NfNew*NfNew*4, &tmpg, NfNew*NfNew*4, &tmpgp, NfNew*NfNew*4, &tmpgt, NfNew, &tmpr, NfNew, &tmpctx);CHKERRQ(ierr); 3742764a2aaSMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpobj[f] = prob->obj[f]; 3752764a2aaSMatthew G. Knepley for (f = 0; f < Nf*2; ++f) tmpf[f] = prob->f[f]; 3762764a2aaSMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpg[f] = prob->g[f]; 377475e0ac9SMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpgp[f] = prob->gp[f]; 3780c2f2876SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpr[f] = prob->r[f]; 3790c2f2876SMatthew G. Knepley for (f = 0; f < Nf; ++f) tmpctx[f] = prob->ctx[f]; 3802764a2aaSMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpobj[f] = NULL; 3812764a2aaSMatthew G. Knepley for (f = Nf*2; f < NfNew*2; ++f) tmpf[f] = NULL; 3822764a2aaSMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpg[f] = NULL; 383475e0ac9SMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgp[f] = NULL; 384*b7e05686SMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgt[f] = NULL; 3850c2f2876SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpr[f] = NULL; 3860c2f2876SMatthew G. Knepley for (f = Nf; f < NfNew; ++f) tmpctx[f] = NULL; 387*b7e05686SMatthew G. Knepley ierr = PetscFree7(prob->obj, prob->f, prob->g, prob->gp, prob->gt, prob->r, prob->ctx);CHKERRQ(ierr); 3882764a2aaSMatthew G. Knepley prob->obj = tmpobj; 3892764a2aaSMatthew G. Knepley prob->f = tmpf; 3902764a2aaSMatthew G. Knepley prob->g = tmpg; 391475e0ac9SMatthew G. Knepley prob->gp = tmpgp; 392*b7e05686SMatthew G. Knepley prob->gt = tmpgt; 3930c2f2876SMatthew G. Knepley prob->r = tmpr; 3940c2f2876SMatthew G. Knepley prob->ctx = tmpctx; 3952764a2aaSMatthew G. Knepley ierr = PetscCalloc2(NfNew*2, &tmpfbd, NfNew*NfNew*4, &tmpgbd);CHKERRQ(ierr); 3962764a2aaSMatthew G. Knepley for (f = 0; f < Nf*2; ++f) tmpfbd[f] = prob->fBd[f]; 3972764a2aaSMatthew G. Knepley for (f = 0; f < Nf*Nf*4; ++f) tmpgbd[f] = prob->gBd[f]; 3982764a2aaSMatthew G. Knepley for (f = Nf*2; f < NfNew*2; ++f) tmpfbd[f] = NULL; 3992764a2aaSMatthew G. Knepley for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgbd[f] = NULL; 4002764a2aaSMatthew G. Knepley ierr = PetscFree2(prob->fBd, prob->gBd);CHKERRQ(ierr); 4012764a2aaSMatthew G. Knepley prob->fBd = tmpfbd; 4022764a2aaSMatthew G. Knepley prob->gBd = tmpgbd; 4032764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4042764a2aaSMatthew G. Knepley } 4052764a2aaSMatthew G. Knepley 4062764a2aaSMatthew G. Knepley #undef __FUNCT__ 4072764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroy" 4082764a2aaSMatthew G. Knepley /*@ 4092764a2aaSMatthew G. Knepley PetscDSDestroy - Destroys a PetscDS object 4102764a2aaSMatthew G. Knepley 4112764a2aaSMatthew G. Knepley Collective on PetscDS 4122764a2aaSMatthew G. Knepley 4132764a2aaSMatthew G. Knepley Input Parameter: 4142764a2aaSMatthew G. Knepley . prob - the PetscDS object to destroy 4152764a2aaSMatthew G. Knepley 4162764a2aaSMatthew G. Knepley Level: developer 4172764a2aaSMatthew G. Knepley 4182764a2aaSMatthew G. Knepley .seealso PetscDSView() 4192764a2aaSMatthew G. Knepley @*/ 4202764a2aaSMatthew G. Knepley PetscErrorCode PetscDSDestroy(PetscDS *prob) 4212764a2aaSMatthew G. Knepley { 4222764a2aaSMatthew G. Knepley PetscInt f; 4232764a2aaSMatthew G. Knepley PetscErrorCode ierr; 4242764a2aaSMatthew G. Knepley 4252764a2aaSMatthew G. Knepley PetscFunctionBegin; 4262764a2aaSMatthew G. Knepley if (!*prob) PetscFunctionReturn(0); 4272764a2aaSMatthew G. Knepley PetscValidHeaderSpecific((*prob), PETSCDS_CLASSID, 1); 4282764a2aaSMatthew G. Knepley 4292764a2aaSMatthew G. Knepley if (--((PetscObject)(*prob))->refct > 0) {*prob = 0; PetscFunctionReturn(0);} 4302764a2aaSMatthew G. Knepley ((PetscObject) (*prob))->refct = 0; 4312764a2aaSMatthew G. Knepley ierr = PetscDSDestroyStructs_Static(*prob);CHKERRQ(ierr); 4322764a2aaSMatthew G. Knepley for (f = 0; f < (*prob)->Nf; ++f) { 4332764a2aaSMatthew G. Knepley ierr = PetscObjectDereference((*prob)->disc[f]);CHKERRQ(ierr); 4342764a2aaSMatthew G. Knepley ierr = PetscObjectDereference((*prob)->discBd[f]);CHKERRQ(ierr); 4352764a2aaSMatthew G. Knepley } 436a6cbbb48SMatthew G. Knepley ierr = PetscFree4((*prob)->disc, (*prob)->discBd, (*prob)->implicit, (*prob)->adjacency);CHKERRQ(ierr); 437*b7e05686SMatthew G. Knepley ierr = PetscFree7((*prob)->obj,(*prob)->f,(*prob)->g,(*prob)->gp,(*prob)->gt,(*prob)->r,(*prob)->ctx);CHKERRQ(ierr); 4382764a2aaSMatthew G. Knepley ierr = PetscFree2((*prob)->fBd,(*prob)->gBd);CHKERRQ(ierr); 4392764a2aaSMatthew G. Knepley if ((*prob)->ops->destroy) {ierr = (*(*prob)->ops->destroy)(*prob);CHKERRQ(ierr);} 4402764a2aaSMatthew G. Knepley ierr = PetscHeaderDestroy(prob);CHKERRQ(ierr); 4412764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4422764a2aaSMatthew G. Knepley } 4432764a2aaSMatthew G. Knepley 4442764a2aaSMatthew G. Knepley #undef __FUNCT__ 4452764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSCreate" 4462764a2aaSMatthew G. Knepley /*@ 4472764a2aaSMatthew G. Knepley PetscDSCreate - Creates an empty PetscDS object. The type can then be set with PetscDSSetType(). 4482764a2aaSMatthew G. Knepley 4492764a2aaSMatthew G. Knepley Collective on MPI_Comm 4502764a2aaSMatthew G. Knepley 4512764a2aaSMatthew G. Knepley Input Parameter: 4522764a2aaSMatthew G. Knepley . comm - The communicator for the PetscDS object 4532764a2aaSMatthew G. Knepley 4542764a2aaSMatthew G. Knepley Output Parameter: 4552764a2aaSMatthew G. Knepley . prob - The PetscDS object 4562764a2aaSMatthew G. Knepley 4572764a2aaSMatthew G. Knepley Level: beginner 4582764a2aaSMatthew G. Knepley 4592764a2aaSMatthew G. Knepley .seealso: PetscDSSetType(), PETSCDSBASIC 4602764a2aaSMatthew G. Knepley @*/ 4612764a2aaSMatthew G. Knepley PetscErrorCode PetscDSCreate(MPI_Comm comm, PetscDS *prob) 4622764a2aaSMatthew G. Knepley { 4632764a2aaSMatthew G. Knepley PetscDS p; 4642764a2aaSMatthew G. Knepley PetscErrorCode ierr; 4652764a2aaSMatthew G. Knepley 4662764a2aaSMatthew G. Knepley PetscFunctionBegin; 4672764a2aaSMatthew G. Knepley PetscValidPointer(prob, 2); 4682764a2aaSMatthew G. Knepley *prob = NULL; 4692764a2aaSMatthew G. Knepley ierr = PetscDSInitializePackage();CHKERRQ(ierr); 4702764a2aaSMatthew G. Knepley 47173107ff1SLisandro Dalcin ierr = PetscHeaderCreate(p, PETSCDS_CLASSID, "PetscDS", "Discrete System", "PetscDS", comm, PetscDSDestroy, PetscDSView);CHKERRQ(ierr); 4722764a2aaSMatthew G. Knepley 4732764a2aaSMatthew G. Knepley p->Nf = 0; 4742764a2aaSMatthew G. Knepley p->setup = PETSC_FALSE; 4752764a2aaSMatthew G. Knepley 4762764a2aaSMatthew G. Knepley *prob = p; 4772764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 4782764a2aaSMatthew G. Knepley } 4792764a2aaSMatthew G. Knepley 4802764a2aaSMatthew G. Knepley #undef __FUNCT__ 4812764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetNumFields" 482bc4ae4beSMatthew G. Knepley /*@ 483bc4ae4beSMatthew G. Knepley PetscDSGetNumFields - Returns the number of fields in the DS 484bc4ae4beSMatthew G. Knepley 485bc4ae4beSMatthew G. Knepley Not collective 486bc4ae4beSMatthew G. Knepley 487bc4ae4beSMatthew G. Knepley Input Parameter: 488bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 489bc4ae4beSMatthew G. Knepley 490bc4ae4beSMatthew G. Knepley Output Parameter: 491bc4ae4beSMatthew G. Knepley . Nf - The number of fields 492bc4ae4beSMatthew G. Knepley 493bc4ae4beSMatthew G. Knepley Level: beginner 494bc4ae4beSMatthew G. Knepley 495bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetSpatialDimension(), PetscDSCreate() 496bc4ae4beSMatthew G. Knepley @*/ 4972764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetNumFields(PetscDS prob, PetscInt *Nf) 4982764a2aaSMatthew G. Knepley { 4992764a2aaSMatthew G. Knepley PetscFunctionBegin; 5002764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 5012764a2aaSMatthew G. Knepley PetscValidPointer(Nf, 2); 5022764a2aaSMatthew G. Knepley *Nf = prob->Nf; 5032764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5042764a2aaSMatthew G. Knepley } 5052764a2aaSMatthew G. Knepley 5062764a2aaSMatthew G. Knepley #undef __FUNCT__ 5072764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetSpatialDimension" 508bc4ae4beSMatthew G. Knepley /*@ 509bc4ae4beSMatthew G. Knepley PetscDSGetSpatialDimension - Returns the spatial dimension of the DS 510bc4ae4beSMatthew G. Knepley 511bc4ae4beSMatthew G. Knepley Not collective 512bc4ae4beSMatthew G. Knepley 513bc4ae4beSMatthew G. Knepley Input Parameter: 514bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 515bc4ae4beSMatthew G. Knepley 516bc4ae4beSMatthew G. Knepley Output Parameter: 517bc4ae4beSMatthew G. Knepley . dim - The spatial dimension 518bc4ae4beSMatthew G. Knepley 519bc4ae4beSMatthew G. Knepley Level: beginner 520bc4ae4beSMatthew G. Knepley 521bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 522bc4ae4beSMatthew G. Knepley @*/ 5232764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetSpatialDimension(PetscDS prob, PetscInt *dim) 5242764a2aaSMatthew G. Knepley { 5252764a2aaSMatthew G. Knepley PetscErrorCode ierr; 5262764a2aaSMatthew G. Knepley 5272764a2aaSMatthew G. Knepley PetscFunctionBegin; 5282764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 5292764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 5302764a2aaSMatthew G. Knepley *dim = 0; 5319de99aefSMatthew G. Knepley if (prob->Nf) { 5329de99aefSMatthew G. Knepley PetscObject obj; 5339de99aefSMatthew G. Knepley PetscClassId id; 5349de99aefSMatthew G. Knepley 5359de99aefSMatthew G. Knepley ierr = PetscDSGetDiscretization(prob, 0, &obj);CHKERRQ(ierr); 5369de99aefSMatthew G. Knepley ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr); 5379de99aefSMatthew G. Knepley if (id == PETSCFE_CLASSID) {ierr = PetscFEGetSpatialDimension((PetscFE) obj, dim);CHKERRQ(ierr);} 5389de99aefSMatthew G. Knepley else if (id == PETSCFV_CLASSID) {ierr = PetscFVGetSpatialDimension((PetscFV) obj, dim);CHKERRQ(ierr);} 5399de99aefSMatthew G. Knepley else SETERRQ1(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", 0); 5409de99aefSMatthew G. Knepley } 5412764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5422764a2aaSMatthew G. Knepley } 5432764a2aaSMatthew G. Knepley 5442764a2aaSMatthew G. Knepley #undef __FUNCT__ 5452764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalDimension" 546bc4ae4beSMatthew G. Knepley /*@ 547bc4ae4beSMatthew G. Knepley PetscDSGetTotalDimension - Returns the total size of the approximation space for this system 548bc4ae4beSMatthew G. Knepley 549bc4ae4beSMatthew G. Knepley Not collective 550bc4ae4beSMatthew G. Knepley 551bc4ae4beSMatthew G. Knepley Input Parameter: 552bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 553bc4ae4beSMatthew G. Knepley 554bc4ae4beSMatthew G. Knepley Output Parameter: 555bc4ae4beSMatthew G. Knepley . dim - The total problem dimension 556bc4ae4beSMatthew G. Knepley 557bc4ae4beSMatthew G. Knepley Level: beginner 558bc4ae4beSMatthew G. Knepley 559bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 560bc4ae4beSMatthew G. Knepley @*/ 5612764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalDimension(PetscDS prob, PetscInt *dim) 5622764a2aaSMatthew G. Knepley { 5632764a2aaSMatthew G. Knepley PetscErrorCode ierr; 5642764a2aaSMatthew G. Knepley 5652764a2aaSMatthew G. Knepley PetscFunctionBegin; 5662764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 5672764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 5682764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 5692764a2aaSMatthew G. Knepley *dim = prob->totDim; 5702764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 5712764a2aaSMatthew G. Knepley } 5722764a2aaSMatthew G. Knepley 5732764a2aaSMatthew G. Knepley #undef __FUNCT__ 5742764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalBdDimension" 575bc4ae4beSMatthew G. Knepley /*@ 576c3ac4435SMatthew G. Knepley PetscDSGetTotalBdDimension - Returns the total size of the boundary approximation space for this system 577bc4ae4beSMatthew G. Knepley 578bc4ae4beSMatthew G. Knepley Not collective 579bc4ae4beSMatthew G. Knepley 580bc4ae4beSMatthew G. Knepley Input Parameter: 581bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 582bc4ae4beSMatthew G. Knepley 583bc4ae4beSMatthew G. Knepley Output Parameter: 584bc4ae4beSMatthew G. Knepley . dim - The total boundary problem dimension 585bc4ae4beSMatthew G. Knepley 586bc4ae4beSMatthew G. Knepley Level: beginner 587bc4ae4beSMatthew G. Knepley 588bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 589bc4ae4beSMatthew G. Knepley @*/ 5902764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalBdDimension(PetscDS prob, PetscInt *dim) 5912764a2aaSMatthew G. Knepley { 5922764a2aaSMatthew G. Knepley PetscErrorCode ierr; 5932764a2aaSMatthew G. Knepley 5942764a2aaSMatthew G. Knepley PetscFunctionBegin; 5952764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 5962764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 5972764a2aaSMatthew G. Knepley PetscValidPointer(dim, 2); 5982764a2aaSMatthew G. Knepley *dim = prob->totDimBd; 5992764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6002764a2aaSMatthew G. Knepley } 6012764a2aaSMatthew G. Knepley 6022764a2aaSMatthew G. Knepley #undef __FUNCT__ 6032764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalComponents" 604bc4ae4beSMatthew G. Knepley /*@ 605bc4ae4beSMatthew G. Knepley PetscDSGetTotalComponents - Returns the total number of components in this system 606bc4ae4beSMatthew G. Knepley 607bc4ae4beSMatthew G. Knepley Not collective 608bc4ae4beSMatthew G. Knepley 609bc4ae4beSMatthew G. Knepley Input Parameter: 610bc4ae4beSMatthew G. Knepley . prob - The PetscDS object 611bc4ae4beSMatthew G. Knepley 612bc4ae4beSMatthew G. Knepley Output Parameter: 613bc4ae4beSMatthew G. Knepley . dim - The total number of components 614bc4ae4beSMatthew G. Knepley 615bc4ae4beSMatthew G. Knepley Level: beginner 616bc4ae4beSMatthew G. Knepley 617bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetNumFields(), PetscDSCreate() 618bc4ae4beSMatthew G. Knepley @*/ 6192764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalComponents(PetscDS prob, PetscInt *Nc) 6202764a2aaSMatthew G. Knepley { 6212764a2aaSMatthew G. Knepley PetscErrorCode ierr; 6222764a2aaSMatthew G. Knepley 6232764a2aaSMatthew G. Knepley PetscFunctionBegin; 6242764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6252764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 6262764a2aaSMatthew G. Knepley PetscValidPointer(Nc, 2); 6272764a2aaSMatthew G. Knepley *Nc = prob->totComp; 6282764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6292764a2aaSMatthew G. Knepley } 6302764a2aaSMatthew G. Knepley 6312764a2aaSMatthew G. Knepley #undef __FUNCT__ 6322764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetDiscretization" 633bc4ae4beSMatthew G. Knepley /*@ 634bc4ae4beSMatthew G. Knepley PetscDSGetDiscretization - Returns the discretization object for the given field 635bc4ae4beSMatthew G. Knepley 636bc4ae4beSMatthew G. Knepley Not collective 637bc4ae4beSMatthew G. Knepley 638bc4ae4beSMatthew G. Knepley Input Parameters: 639bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 640bc4ae4beSMatthew G. Knepley - f - The field number 641bc4ae4beSMatthew G. Knepley 642bc4ae4beSMatthew G. Knepley Output Parameter: 643bc4ae4beSMatthew G. Knepley . disc - The discretization object 644bc4ae4beSMatthew G. Knepley 645bc4ae4beSMatthew G. Knepley Level: beginner 646bc4ae4beSMatthew G. Knepley 647bc4ae4beSMatthew G. Knepley .seealso: PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 648bc4ae4beSMatthew G. Knepley @*/ 6492764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetDiscretization(PetscDS prob, PetscInt f, PetscObject *disc) 6502764a2aaSMatthew G. Knepley { 6512764a2aaSMatthew G. Knepley PetscFunctionBegin; 6522764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6532764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 6542764a2aaSMatthew 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); 6552764a2aaSMatthew G. Knepley *disc = prob->disc[f]; 6562764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6572764a2aaSMatthew G. Knepley } 6582764a2aaSMatthew G. Knepley 6592764a2aaSMatthew G. Knepley #undef __FUNCT__ 6602764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdDiscretization" 661bc4ae4beSMatthew G. Knepley /*@ 662bc4ae4beSMatthew G. Knepley PetscDSGetBdDiscretization - Returns the boundary discretization object for the given field 663bc4ae4beSMatthew G. Knepley 664bc4ae4beSMatthew G. Knepley Not collective 665bc4ae4beSMatthew G. Knepley 666bc4ae4beSMatthew G. Knepley Input Parameters: 667bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 668bc4ae4beSMatthew G. Knepley - f - The field number 669bc4ae4beSMatthew G. Knepley 670bc4ae4beSMatthew G. Knepley Output Parameter: 671bc4ae4beSMatthew G. Knepley . disc - The boundary discretization object 672bc4ae4beSMatthew G. Knepley 673bc4ae4beSMatthew G. Knepley Level: beginner 674bc4ae4beSMatthew G. Knepley 675bc4ae4beSMatthew G. Knepley .seealso: PetscDSSetBdDiscretization(), PetscDSAddBdDiscretization(), PetscDSGetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 676bc4ae4beSMatthew G. Knepley @*/ 6772764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdDiscretization(PetscDS prob, PetscInt f, PetscObject *disc) 6782764a2aaSMatthew G. Knepley { 6792764a2aaSMatthew G. Knepley PetscFunctionBegin; 6802764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 6812764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 6822764a2aaSMatthew 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); 6832764a2aaSMatthew G. Knepley *disc = prob->discBd[f]; 6842764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 6852764a2aaSMatthew G. Knepley } 6862764a2aaSMatthew G. Knepley 6872764a2aaSMatthew G. Knepley #undef __FUNCT__ 6882764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetDiscretization" 689bc4ae4beSMatthew G. Knepley /*@ 690bc4ae4beSMatthew G. Knepley PetscDSSetDiscretization - Sets the discretization object for the given field 691bc4ae4beSMatthew G. Knepley 692bc4ae4beSMatthew G. Knepley Not collective 693bc4ae4beSMatthew G. Knepley 694bc4ae4beSMatthew G. Knepley Input Parameters: 695bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 696bc4ae4beSMatthew G. Knepley . f - The field number 697bc4ae4beSMatthew G. Knepley - disc - The discretization object 698bc4ae4beSMatthew G. Knepley 699bc4ae4beSMatthew G. Knepley Level: beginner 700bc4ae4beSMatthew G. Knepley 701bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSAddDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 702bc4ae4beSMatthew G. Knepley @*/ 7032764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetDiscretization(PetscDS prob, PetscInt f, PetscObject disc) 7042764a2aaSMatthew G. Knepley { 7052764a2aaSMatthew G. Knepley PetscErrorCode ierr; 7062764a2aaSMatthew G. Knepley 7072764a2aaSMatthew G. Knepley PetscFunctionBegin; 7082764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7092764a2aaSMatthew G. Knepley PetscValidPointer(disc, 3); 7102764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 7112764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 7122764a2aaSMatthew G. Knepley if (prob->disc[f]) {ierr = PetscObjectDereference(prob->disc[f]);CHKERRQ(ierr);} 7132764a2aaSMatthew G. Knepley prob->disc[f] = disc; 7142764a2aaSMatthew G. Knepley ierr = PetscObjectReference(disc);CHKERRQ(ierr); 715249df284SMatthew G. Knepley { 716249df284SMatthew G. Knepley PetscClassId id; 717249df284SMatthew G. Knepley 718249df284SMatthew G. Knepley ierr = PetscObjectGetClassId(disc, &id);CHKERRQ(ierr); 719a6cbbb48SMatthew G. Knepley if (id == PETSCFV_CLASSID) { 720a6cbbb48SMatthew G. Knepley prob->implicit[f] = PETSC_FALSE; 721a6cbbb48SMatthew G. Knepley prob->adjacency[f*2+0] = PETSC_TRUE; 722a6cbbb48SMatthew G. Knepley prob->adjacency[f*2+1] = PETSC_FALSE; 723a6cbbb48SMatthew G. Knepley } 724249df284SMatthew G. Knepley } 7252764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7262764a2aaSMatthew G. Knepley } 7272764a2aaSMatthew G. Knepley 7282764a2aaSMatthew G. Knepley #undef __FUNCT__ 7292764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdDiscretization" 730bc4ae4beSMatthew G. Knepley /*@ 731bc4ae4beSMatthew G. Knepley PetscDSSetBdDiscretization - Sets the boundary discretization object for the given field 732bc4ae4beSMatthew G. Knepley 733bc4ae4beSMatthew G. Knepley Not collective 734bc4ae4beSMatthew G. Knepley 735bc4ae4beSMatthew G. Knepley Input Parameters: 736bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 737bc4ae4beSMatthew G. Knepley . f - The field number 738bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object 739bc4ae4beSMatthew G. Knepley 740bc4ae4beSMatthew G. Knepley Level: beginner 741bc4ae4beSMatthew G. Knepley 742bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetBdDiscretization(), PetscDSAddBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 743bc4ae4beSMatthew G. Knepley @*/ 7442764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdDiscretization(PetscDS prob, PetscInt f, PetscObject disc) 7452764a2aaSMatthew G. Knepley { 7462764a2aaSMatthew G. Knepley PetscErrorCode ierr; 7472764a2aaSMatthew G. Knepley 7482764a2aaSMatthew G. Knepley PetscFunctionBegin; 7492764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 7502764a2aaSMatthew G. Knepley if (disc) PetscValidPointer(disc, 3); 7512764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 7522764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 7532764a2aaSMatthew G. Knepley if (prob->discBd[f]) {ierr = PetscObjectDereference(prob->discBd[f]);CHKERRQ(ierr);} 7542764a2aaSMatthew G. Knepley prob->discBd[f] = disc; 7552764a2aaSMatthew G. Knepley ierr = PetscObjectReference(disc);CHKERRQ(ierr); 7562764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7572764a2aaSMatthew G. Knepley } 7582764a2aaSMatthew G. Knepley 7592764a2aaSMatthew G. Knepley #undef __FUNCT__ 7602764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSAddDiscretization" 761bc4ae4beSMatthew G. Knepley /*@ 762bc4ae4beSMatthew G. Knepley PetscDSAddDiscretization - Adds a discretization object 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 - disc - The boundary discretization object 769bc4ae4beSMatthew G. Knepley 770bc4ae4beSMatthew G. Knepley Level: beginner 771bc4ae4beSMatthew G. Knepley 772bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetDiscretization(), PetscDSSetDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 773bc4ae4beSMatthew G. Knepley @*/ 7742764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddDiscretization(PetscDS prob, PetscObject disc) 7752764a2aaSMatthew G. Knepley { 7762764a2aaSMatthew G. Knepley PetscErrorCode ierr; 7772764a2aaSMatthew G. Knepley 7782764a2aaSMatthew G. Knepley PetscFunctionBegin; 7792764a2aaSMatthew G. Knepley ierr = PetscDSSetDiscretization(prob, prob->Nf, disc);CHKERRQ(ierr); 7802764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 7812764a2aaSMatthew G. Knepley } 7822764a2aaSMatthew G. Knepley 7832764a2aaSMatthew G. Knepley #undef __FUNCT__ 7842764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSAddBdDiscretization" 785bc4ae4beSMatthew G. Knepley /*@ 786bc4ae4beSMatthew G. Knepley PetscDSAddBdDiscretization - Adds a boundary discretization object 787bc4ae4beSMatthew G. Knepley 788bc4ae4beSMatthew G. Knepley Not collective 789bc4ae4beSMatthew G. Knepley 790bc4ae4beSMatthew G. Knepley Input Parameters: 791bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 792bc4ae4beSMatthew G. Knepley - disc - The boundary discretization object 793bc4ae4beSMatthew G. Knepley 794bc4ae4beSMatthew G. Knepley Level: beginner 795bc4ae4beSMatthew G. Knepley 796bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetBdDiscretization(), PetscDSSetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 797bc4ae4beSMatthew G. Knepley @*/ 7982764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddBdDiscretization(PetscDS prob, PetscObject disc) 7992764a2aaSMatthew G. Knepley { 8002764a2aaSMatthew G. Knepley PetscErrorCode ierr; 8012764a2aaSMatthew G. Knepley 8022764a2aaSMatthew G. Knepley PetscFunctionBegin; 8032764a2aaSMatthew G. Knepley ierr = PetscDSSetBdDiscretization(prob, prob->Nf, disc);CHKERRQ(ierr); 8042764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 8052764a2aaSMatthew G. Knepley } 8062764a2aaSMatthew G. Knepley 8072764a2aaSMatthew G. Knepley #undef __FUNCT__ 808249df284SMatthew G. Knepley #define __FUNCT__ "PetscDSGetImplicit" 809249df284SMatthew G. Knepley /*@ 810249df284SMatthew G. Knepley PetscDSGetImplicit - Returns the flag for implicit solve for this field. This is just a guide for IMEX 811249df284SMatthew G. Knepley 812249df284SMatthew G. Knepley Not collective 813249df284SMatthew G. Knepley 814249df284SMatthew G. Knepley Input Parameters: 815249df284SMatthew G. Knepley + prob - The PetscDS object 816249df284SMatthew G. Knepley - f - The field number 817249df284SMatthew G. Knepley 818249df284SMatthew G. Knepley Output Parameter: 819249df284SMatthew G. Knepley . implicit - The flag indicating what kind of solve to use for this field 820249df284SMatthew G. Knepley 821249df284SMatthew G. Knepley Level: developer 822249df284SMatthew G. Knepley 823249df284SMatthew G. Knepley .seealso: PetscDSSetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 824249df284SMatthew G. Knepley @*/ 825249df284SMatthew G. Knepley PetscErrorCode PetscDSGetImplicit(PetscDS prob, PetscInt f, PetscBool *implicit) 826249df284SMatthew G. Knepley { 827249df284SMatthew G. Knepley PetscFunctionBegin; 828249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 829249df284SMatthew G. Knepley PetscValidPointer(implicit, 3); 830249df284SMatthew 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); 831249df284SMatthew G. Knepley *implicit = prob->implicit[f]; 832249df284SMatthew G. Knepley PetscFunctionReturn(0); 833249df284SMatthew G. Knepley } 834249df284SMatthew G. Knepley 835249df284SMatthew G. Knepley #undef __FUNCT__ 836249df284SMatthew G. Knepley #define __FUNCT__ "PetscDSSetImplicit" 837249df284SMatthew G. Knepley /*@ 838249df284SMatthew G. Knepley PetscDSSetImplicit - Set the flag for implicit solve for this field. This is just a guide for IMEX 839249df284SMatthew G. Knepley 840249df284SMatthew G. Knepley Not collective 841249df284SMatthew G. Knepley 842249df284SMatthew G. Knepley Input Parameters: 843249df284SMatthew G. Knepley + prob - The PetscDS object 844249df284SMatthew G. Knepley . f - The field number 845249df284SMatthew G. Knepley - implicit - The flag indicating what kind of solve to use for this field 846249df284SMatthew G. Knepley 847249df284SMatthew G. Knepley Level: developer 848249df284SMatthew G. Knepley 849249df284SMatthew G. Knepley .seealso: PetscDSGetImplicit(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 850249df284SMatthew G. Knepley @*/ 851249df284SMatthew G. Knepley PetscErrorCode PetscDSSetImplicit(PetscDS prob, PetscInt f, PetscBool implicit) 852249df284SMatthew G. Knepley { 853249df284SMatthew G. Knepley PetscFunctionBegin; 854249df284SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 855249df284SMatthew 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); 856249df284SMatthew G. Knepley prob->implicit[f] = implicit; 857249df284SMatthew G. Knepley PetscFunctionReturn(0); 858249df284SMatthew G. Knepley } 859249df284SMatthew G. Knepley 860249df284SMatthew G. Knepley #undef __FUNCT__ 861a6cbbb48SMatthew G. Knepley #define __FUNCT__ "PetscDSGetAdjacency" 862a6cbbb48SMatthew G. Knepley /*@ 863a6cbbb48SMatthew G. Knepley PetscDSGetAdjacency - Returns the flags for determining variable influence 864a6cbbb48SMatthew G. Knepley 865a6cbbb48SMatthew G. Knepley Not collective 866a6cbbb48SMatthew G. Knepley 867a6cbbb48SMatthew G. Knepley Input Parameters: 868a6cbbb48SMatthew G. Knepley + prob - The PetscDS object 869a6cbbb48SMatthew G. Knepley - f - The field number 870a6cbbb48SMatthew G. Knepley 871a6cbbb48SMatthew G. Knepley Output Parameter: 872a6cbbb48SMatthew G. Knepley + useCone - Flag for variable influence starting with the cone operation 873a6cbbb48SMatthew G. Knepley - useClosure - Flag for variable influence using transitive closure 874a6cbbb48SMatthew G. Knepley 875a6cbbb48SMatthew G. Knepley Note: See the discussion in DMPlexGetAdjacencyUseCone() and DMPlexGetAdjacencyUseClosure() 876a6cbbb48SMatthew G. Knepley 877a6cbbb48SMatthew G. Knepley Level: developer 878a6cbbb48SMatthew G. Knepley 879a6cbbb48SMatthew G. Knepley .seealso: PetscDSSetAdjacency(), DMPlexGetAdjacencyUseCone(), DMPlexGetAdjacencyUseClosure(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 880a6cbbb48SMatthew G. Knepley @*/ 881a6cbbb48SMatthew G. Knepley PetscErrorCode PetscDSGetAdjacency(PetscDS prob, PetscInt f, PetscBool *useCone, PetscBool *useClosure) 882a6cbbb48SMatthew G. Knepley { 883a6cbbb48SMatthew G. Knepley PetscFunctionBegin; 884a6cbbb48SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 885a6cbbb48SMatthew G. Knepley PetscValidPointer(useCone, 3); 886a6cbbb48SMatthew G. Knepley PetscValidPointer(useClosure, 4); 887a6cbbb48SMatthew 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); 888a6cbbb48SMatthew G. Knepley *useCone = prob->adjacency[f*2+0]; 889a6cbbb48SMatthew G. Knepley *useClosure = prob->adjacency[f*2+1]; 890a6cbbb48SMatthew G. Knepley PetscFunctionReturn(0); 891a6cbbb48SMatthew G. Knepley } 892a6cbbb48SMatthew G. Knepley 893a6cbbb48SMatthew G. Knepley #undef __FUNCT__ 894a6cbbb48SMatthew G. Knepley #define __FUNCT__ "PetscDSSetAdjacency" 895a6cbbb48SMatthew G. Knepley /*@ 896a6cbbb48SMatthew G. Knepley PetscDSSetAdjacency - Set the flags for determining variable influence 897a6cbbb48SMatthew G. Knepley 898a6cbbb48SMatthew G. Knepley Not collective 899a6cbbb48SMatthew G. Knepley 900a6cbbb48SMatthew G. Knepley Input Parameters: 901a6cbbb48SMatthew G. Knepley + prob - The PetscDS object 902a6cbbb48SMatthew G. Knepley . f - The field number 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: PetscDSGetAdjacency(), DMPlexGetAdjacencyUseCone(), DMPlexGetAdjacencyUseClosure(), PetscDSSetDiscretization(), PetscDSAddDiscretization(), PetscDSGetBdDiscretization(), PetscDSGetNumFields(), PetscDSCreate() 911a6cbbb48SMatthew G. Knepley @*/ 912a6cbbb48SMatthew G. Knepley PetscErrorCode PetscDSSetAdjacency(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 if ((f < 0) || (f >= prob->Nf)) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be in [0, %d)", f, prob->Nf); 917a6cbbb48SMatthew G. Knepley prob->adjacency[f*2+0] = useCone; 918a6cbbb48SMatthew G. Knepley prob->adjacency[f*2+1] = useClosure; 919a6cbbb48SMatthew G. Knepley PetscFunctionReturn(0); 920a6cbbb48SMatthew G. Knepley } 921a6cbbb48SMatthew G. Knepley 922a6cbbb48SMatthew G. Knepley #undef __FUNCT__ 9232764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetObjective" 9242764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetObjective(PetscDS prob, PetscInt f, 92530b9ff8bSMatthew G. Knepley void (**obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 926194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 927194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 92830b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar obj[])) 9292764a2aaSMatthew G. Knepley { 9302764a2aaSMatthew G. Knepley PetscFunctionBegin; 9312764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 9322764a2aaSMatthew G. Knepley PetscValidPointer(obj, 2); 9332764a2aaSMatthew 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); 9342764a2aaSMatthew G. Knepley *obj = prob->obj[f]; 9352764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9362764a2aaSMatthew G. Knepley } 9372764a2aaSMatthew G. Knepley 9382764a2aaSMatthew G. Knepley #undef __FUNCT__ 9392764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetObjective" 9402764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetObjective(PetscDS prob, PetscInt f, 94130b9ff8bSMatthew G. Knepley void (*obj)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 942194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 943194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 94430b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar obj[])) 9452764a2aaSMatthew G. Knepley { 9462764a2aaSMatthew G. Knepley PetscErrorCode ierr; 9472764a2aaSMatthew G. Knepley 9482764a2aaSMatthew G. Knepley PetscFunctionBegin; 9492764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 9502764a2aaSMatthew G. Knepley PetscValidFunction(obj, 2); 9512764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 9522764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 9532764a2aaSMatthew G. Knepley prob->obj[f] = obj; 9542764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 9552764a2aaSMatthew G. Knepley } 9562764a2aaSMatthew G. Knepley 9572764a2aaSMatthew G. Knepley #undef __FUNCT__ 9582764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetResidual" 959194d53e6SMatthew G. Knepley /*@C 960194d53e6SMatthew G. Knepley PetscDSGetResidual - Get the pointwise residual function for a given test field 961194d53e6SMatthew G. Knepley 962194d53e6SMatthew G. Knepley Not collective 963194d53e6SMatthew G. Knepley 964194d53e6SMatthew G. Knepley Input Parameters: 965194d53e6SMatthew G. Knepley + prob - The PetscDS 966194d53e6SMatthew G. Knepley - f - The test field number 967194d53e6SMatthew G. Knepley 968194d53e6SMatthew G. Knepley Output Parameters: 969194d53e6SMatthew G. Knepley + f0 - integrand for the test function term 970194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 971194d53e6SMatthew G. Knepley 972194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 973194d53e6SMatthew G. Knepley 974194d53e6SMatthew 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) 975194d53e6SMatthew G. Knepley 976194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 977194d53e6SMatthew G. Knepley 97830b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 979194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 980194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 98130b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 982194d53e6SMatthew G. Knepley 983194d53e6SMatthew G. Knepley + dim - the spatial dimension 984194d53e6SMatthew G. Knepley . Nf - the number of fields 985194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 986194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 987194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 988194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 989194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 990194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 991194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 992194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 993194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 994194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 995194d53e6SMatthew G. Knepley . t - current time 996194d53e6SMatthew G. Knepley . x - coordinates of the current point 997194d53e6SMatthew G. Knepley - f0 - output values at the current point 998194d53e6SMatthew G. Knepley 999194d53e6SMatthew G. Knepley Level: intermediate 1000194d53e6SMatthew G. Knepley 1001194d53e6SMatthew G. Knepley .seealso: PetscDSSetResidual() 1002194d53e6SMatthew G. Knepley @*/ 10032764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetResidual(PetscDS prob, PetscInt f, 100430b9ff8bSMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1005194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1006194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 100730b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar f0[]), 100830b9ff8bSMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1009194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1010194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 101130b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar f1[])) 10122764a2aaSMatthew G. Knepley { 10132764a2aaSMatthew G. Knepley PetscFunctionBegin; 10142764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 10152764a2aaSMatthew 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); 10162764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 3); *f0 = prob->f[f*2+0];} 10172764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 4); *f1 = prob->f[f*2+1];} 10182764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 10192764a2aaSMatthew G. Knepley } 10202764a2aaSMatthew G. Knepley 10212764a2aaSMatthew G. Knepley #undef __FUNCT__ 10222764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetResidual" 1023194d53e6SMatthew G. Knepley /*@C 1024194d53e6SMatthew G. Knepley PetscDSSetResidual - Set the pointwise residual function for a given test field 1025194d53e6SMatthew G. Knepley 1026194d53e6SMatthew G. Knepley Not collective 1027194d53e6SMatthew G. Knepley 1028194d53e6SMatthew G. Knepley Input Parameters: 1029194d53e6SMatthew G. Knepley + prob - The PetscDS 1030194d53e6SMatthew G. Knepley . f - The test field number 1031194d53e6SMatthew G. Knepley . f0 - integrand for the test function term 1032194d53e6SMatthew G. Knepley - f1 - integrand for the test function gradient term 1033194d53e6SMatthew G. Knepley 1034194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1035194d53e6SMatthew G. Knepley 1036194d53e6SMatthew 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) 1037194d53e6SMatthew G. Knepley 1038194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1039194d53e6SMatthew G. Knepley 104030b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1041194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1042194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 104330b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar f0[]) 1044194d53e6SMatthew G. Knepley 1045194d53e6SMatthew G. Knepley + dim - the spatial dimension 1046194d53e6SMatthew G. Knepley . Nf - the number of fields 1047194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1048194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1049194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1050194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1051194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1052194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1053194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1054194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1055194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1056194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1057194d53e6SMatthew G. Knepley . t - current time 1058194d53e6SMatthew G. Knepley . x - coordinates of the current point 1059194d53e6SMatthew G. Knepley - f0 - output values at the current point 1060194d53e6SMatthew G. Knepley 1061194d53e6SMatthew G. Knepley Level: intermediate 1062194d53e6SMatthew G. Knepley 1063194d53e6SMatthew G. Knepley .seealso: PetscDSGetResidual() 1064194d53e6SMatthew G. Knepley @*/ 10652764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetResidual(PetscDS prob, PetscInt f, 106630b9ff8bSMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1067194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1068194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 106930b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar f0[]), 107030b9ff8bSMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1071194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1072194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 107330b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], PetscScalar f1[])) 10742764a2aaSMatthew G. Knepley { 10752764a2aaSMatthew G. Knepley PetscErrorCode ierr; 10762764a2aaSMatthew G. Knepley 10772764a2aaSMatthew G. Knepley PetscFunctionBegin; 10782764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1079f866a1d0SMatthew G. Knepley if (f0) PetscValidFunction(f0, 3); 1080f866a1d0SMatthew G. Knepley if (f1) PetscValidFunction(f1, 4); 10812764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 10822764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 10832764a2aaSMatthew G. Knepley prob->f[f*2+0] = f0; 10842764a2aaSMatthew G. Knepley prob->f[f*2+1] = f1; 10852764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 10862764a2aaSMatthew G. Knepley } 10872764a2aaSMatthew G. Knepley 10882764a2aaSMatthew G. Knepley #undef __FUNCT__ 10892764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetJacobian" 1090194d53e6SMatthew G. Knepley /*@C 1091194d53e6SMatthew G. Knepley PetscDSGetJacobian - Get the pointwise Jacobian function for given test and basis field 1092194d53e6SMatthew G. Knepley 1093194d53e6SMatthew G. Knepley Not collective 1094194d53e6SMatthew G. Knepley 1095194d53e6SMatthew G. Knepley Input Parameters: 1096194d53e6SMatthew G. Knepley + prob - The PetscDS 1097194d53e6SMatthew G. Knepley . f - The test field number 1098194d53e6SMatthew G. Knepley - g - The field number 1099194d53e6SMatthew G. Knepley 1100194d53e6SMatthew G. Knepley Output Parameters: 1101194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 1102194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1103194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1104194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1105194d53e6SMatthew G. Knepley 1106194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1107194d53e6SMatthew G. Knepley 1108194d53e6SMatthew 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 1109194d53e6SMatthew G. Knepley 1110194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1111194d53e6SMatthew G. Knepley 111230b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1113194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1114194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 111530b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1116194d53e6SMatthew G. Knepley 1117194d53e6SMatthew G. Knepley + dim - the spatial dimension 1118194d53e6SMatthew G. Knepley . Nf - the number of fields 1119194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1120194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1121194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1122194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1123194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1124194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1125194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1126194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1127194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1128194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1129194d53e6SMatthew G. Knepley . t - current time 11302aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1131194d53e6SMatthew G. Knepley . x - coordinates of the current point 1132194d53e6SMatthew G. Knepley - g0 - output values at the current point 1133194d53e6SMatthew G. Knepley 1134194d53e6SMatthew G. Knepley Level: intermediate 1135194d53e6SMatthew G. Knepley 1136194d53e6SMatthew G. Knepley .seealso: PetscDSSetJacobian() 1137194d53e6SMatthew G. Knepley @*/ 11382764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetJacobian(PetscDS prob, PetscInt f, PetscInt g, 113930b9ff8bSMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1140194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1141194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 11422aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]), 114330b9ff8bSMatthew G. Knepley void (**g1)(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[], 11462aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]), 114730b9ff8bSMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1148194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1149194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 11502aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]), 115130b9ff8bSMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1152194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1153194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 11542aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[])) 11552764a2aaSMatthew G. Knepley { 11562764a2aaSMatthew G. Knepley PetscFunctionBegin; 11572764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 11582764a2aaSMatthew 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); 11592764a2aaSMatthew 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); 11602764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g[(f*prob->Nf + g)*4+0];} 11612764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g[(f*prob->Nf + g)*4+1];} 11622764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g[(f*prob->Nf + g)*4+2];} 11632764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g[(f*prob->Nf + g)*4+3];} 11642764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 11652764a2aaSMatthew G. Knepley } 11662764a2aaSMatthew G. Knepley 11672764a2aaSMatthew G. Knepley #undef __FUNCT__ 11682764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetJacobian" 1169194d53e6SMatthew G. Knepley /*@C 1170194d53e6SMatthew G. Knepley PetscDSSetJacobian - Set the pointwise Jacobian function for given test and basis fields 1171194d53e6SMatthew G. Knepley 1172194d53e6SMatthew G. Knepley Not collective 1173194d53e6SMatthew G. Knepley 1174194d53e6SMatthew G. Knepley Input Parameters: 1175194d53e6SMatthew G. Knepley + prob - The PetscDS 1176194d53e6SMatthew G. Knepley . f - The test field number 1177194d53e6SMatthew G. Knepley . g - The field number 1178194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 1179194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1180194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1181194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1182194d53e6SMatthew G. Knepley 1183194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1184194d53e6SMatthew G. Knepley 1185194d53e6SMatthew 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 1186194d53e6SMatthew G. Knepley 1187194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1188194d53e6SMatthew G. Knepley 118930b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1190194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1191194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 119230b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1193194d53e6SMatthew G. Knepley 1194194d53e6SMatthew G. Knepley + dim - the spatial dimension 1195194d53e6SMatthew G. Knepley . Nf - the number of fields 1196194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1197194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1198194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1199194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1200194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1201194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1202194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1203194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1204194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1205194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1206194d53e6SMatthew G. Knepley . t - current time 12072aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1208194d53e6SMatthew G. Knepley . x - coordinates of the current point 1209194d53e6SMatthew G. Knepley - g0 - output values at the current point 1210194d53e6SMatthew G. Knepley 1211194d53e6SMatthew G. Knepley Level: intermediate 1212194d53e6SMatthew G. Knepley 1213194d53e6SMatthew G. Knepley .seealso: PetscDSGetJacobian() 1214194d53e6SMatthew G. Knepley @*/ 12152764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetJacobian(PetscDS prob, PetscInt f, PetscInt g, 121630b9ff8bSMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1217194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1218194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 121930b9ff8bSMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]), 122030b9ff8bSMatthew G. Knepley void (*g1)(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[], 122330b9ff8bSMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]), 122430b9ff8bSMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1225194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1226194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 122730b9ff8bSMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]), 122830b9ff8bSMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1229194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1230194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 123130b9ff8bSMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[])) 12322764a2aaSMatthew G. Knepley { 12332764a2aaSMatthew G. Knepley PetscErrorCode ierr; 12342764a2aaSMatthew G. Knepley 12352764a2aaSMatthew G. Knepley PetscFunctionBegin; 12362764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 12372764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 12382764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 12392764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 12402764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 12412764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 12422764a2aaSMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 12432764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 12442764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+0] = g0; 12452764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+1] = g1; 12462764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+2] = g2; 12472764a2aaSMatthew G. Knepley prob->g[(f*prob->Nf + g)*4+3] = g3; 12482764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 12492764a2aaSMatthew G. Knepley } 12502764a2aaSMatthew G. Knepley 12512764a2aaSMatthew G. Knepley #undef __FUNCT__ 1252475e0ac9SMatthew G. Knepley #define __FUNCT__ "PetscDSHasJacobianPreconditioner" 1253475e0ac9SMatthew G. Knepley /*@C 1254475e0ac9SMatthew G. Knepley PetscDSHasJacobianPreconditioner - Signals that a Jacobian preconditioner matrix has been set 1255475e0ac9SMatthew G. Knepley 1256475e0ac9SMatthew G. Knepley Not collective 1257475e0ac9SMatthew G. Knepley 1258475e0ac9SMatthew G. Knepley Input Parameter: 1259475e0ac9SMatthew G. Knepley . prob - The PetscDS 1260475e0ac9SMatthew G. Knepley 1261475e0ac9SMatthew G. Knepley Output Parameter: 1262475e0ac9SMatthew G. Knepley . hasJacPre - flag that pointwise function for Jacobian preconditioner matrix has been set 1263475e0ac9SMatthew G. Knepley 1264475e0ac9SMatthew G. Knepley Level: intermediate 1265475e0ac9SMatthew G. Knepley 1266475e0ac9SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 1267475e0ac9SMatthew G. Knepley @*/ 1268475e0ac9SMatthew G. Knepley PetscErrorCode PetscDSHasJacobianPreconditioner(PetscDS prob, PetscBool *hasJacPre) 1269475e0ac9SMatthew G. Knepley { 1270475e0ac9SMatthew G. Knepley PetscInt f, g, h; 1271475e0ac9SMatthew G. Knepley 1272475e0ac9SMatthew G. Knepley PetscFunctionBegin; 1273475e0ac9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1274475e0ac9SMatthew G. Knepley *hasJacPre = PETSC_FALSE; 1275475e0ac9SMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 1276475e0ac9SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 1277475e0ac9SMatthew G. Knepley for (h = 0; h < 4; ++h) { 1278475e0ac9SMatthew G. Knepley if (prob->gp[(f*prob->Nf + g)*4+h]) *hasJacPre = PETSC_TRUE; 1279475e0ac9SMatthew G. Knepley } 1280475e0ac9SMatthew G. Knepley } 1281475e0ac9SMatthew G. Knepley } 1282475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1283475e0ac9SMatthew G. Knepley } 1284475e0ac9SMatthew G. Knepley 1285475e0ac9SMatthew G. Knepley #undef __FUNCT__ 1286475e0ac9SMatthew G. Knepley #define __FUNCT__ "PetscDSGetJacobianPreconditioner" 1287475e0ac9SMatthew G. Knepley /*@C 1288475e0ac9SMatthew G. Knepley PetscDSGetJacobianPreconditioner - Get the pointwise Jacobian preconditioner function for given test and basis field. If this is missing, the system matrix is used to build the preconditioner. 1289475e0ac9SMatthew G. Knepley 1290475e0ac9SMatthew G. Knepley Not collective 1291475e0ac9SMatthew G. Knepley 1292475e0ac9SMatthew G. Knepley Input Parameters: 1293475e0ac9SMatthew G. Knepley + prob - The PetscDS 1294475e0ac9SMatthew G. Knepley . f - The test field number 1295475e0ac9SMatthew G. Knepley - g - The field number 1296475e0ac9SMatthew G. Knepley 1297475e0ac9SMatthew G. Knepley Output Parameters: 1298475e0ac9SMatthew G. Knepley + g0 - integrand for the test and basis function term 1299475e0ac9SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1300475e0ac9SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1301475e0ac9SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1302475e0ac9SMatthew G. Knepley 1303475e0ac9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1304475e0ac9SMatthew G. Knepley 1305475e0ac9SMatthew 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 1306475e0ac9SMatthew G. Knepley 1307475e0ac9SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1308475e0ac9SMatthew G. Knepley 1309475e0ac9SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1310475e0ac9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1311475e0ac9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1312475e0ac9SMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1313475e0ac9SMatthew G. Knepley 1314475e0ac9SMatthew G. Knepley + dim - the spatial dimension 1315475e0ac9SMatthew G. Knepley . Nf - the number of fields 1316475e0ac9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1317475e0ac9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1318475e0ac9SMatthew G. Knepley . u - each field evaluated at the current point 1319475e0ac9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1320475e0ac9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1321475e0ac9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1322475e0ac9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1323475e0ac9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1324475e0ac9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1325475e0ac9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1326475e0ac9SMatthew G. Knepley . t - current time 1327475e0ac9SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1328475e0ac9SMatthew G. Knepley . x - coordinates of the current point 1329475e0ac9SMatthew G. Knepley - g0 - output values at the current point 1330475e0ac9SMatthew G. Knepley 1331475e0ac9SMatthew G. Knepley Level: intermediate 1332475e0ac9SMatthew G. Knepley 1333475e0ac9SMatthew G. Knepley .seealso: PetscDSSetJacobianPreconditioner(), PetscDSGetJacobian() 1334475e0ac9SMatthew G. Knepley @*/ 1335475e0ac9SMatthew G. Knepley PetscErrorCode PetscDSGetJacobianPreconditioner(PetscDS prob, PetscInt f, PetscInt g, 1336475e0ac9SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1337475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1338475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1339475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]), 1340475e0ac9SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1341475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1342475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1343475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]), 1344475e0ac9SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1345475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1346475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1347475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]), 1348475e0ac9SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1349475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1350475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1351475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[])) 1352475e0ac9SMatthew G. Knepley { 1353475e0ac9SMatthew G. Knepley PetscFunctionBegin; 1354475e0ac9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1355475e0ac9SMatthew 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); 1356475e0ac9SMatthew 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); 1357475e0ac9SMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gp[(f*prob->Nf + g)*4+0];} 1358475e0ac9SMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gp[(f*prob->Nf + g)*4+1];} 1359475e0ac9SMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gp[(f*prob->Nf + g)*4+2];} 1360475e0ac9SMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gp[(f*prob->Nf + g)*4+3];} 1361475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1362475e0ac9SMatthew G. Knepley } 1363475e0ac9SMatthew G. Knepley 1364475e0ac9SMatthew G. Knepley #undef __FUNCT__ 1365475e0ac9SMatthew G. Knepley #define __FUNCT__ "PetscDSSetJacobianPreconditioner" 1366475e0ac9SMatthew G. Knepley /*@C 1367475e0ac9SMatthew G. Knepley PetscDSSetJacobianPreconditioner - Set the pointwise Jacobian preconditioner function for given test and basis fields. If this is missing, the system matrix is used to build the preconditioner. 1368475e0ac9SMatthew G. Knepley 1369475e0ac9SMatthew G. Knepley Not collective 1370475e0ac9SMatthew G. Knepley 1371475e0ac9SMatthew G. Knepley Input Parameters: 1372475e0ac9SMatthew G. Knepley + prob - The PetscDS 1373475e0ac9SMatthew G. Knepley . f - The test field number 1374475e0ac9SMatthew G. Knepley . g - The field number 1375475e0ac9SMatthew G. Knepley . g0 - integrand for the test and basis function term 1376475e0ac9SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1377475e0ac9SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1378475e0ac9SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1379475e0ac9SMatthew G. Knepley 1380475e0ac9SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1381475e0ac9SMatthew G. Knepley 1382475e0ac9SMatthew 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 1383475e0ac9SMatthew G. Knepley 1384475e0ac9SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1385475e0ac9SMatthew G. Knepley 1386475e0ac9SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1387475e0ac9SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1388475e0ac9SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1389475e0ac9SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1390475e0ac9SMatthew G. Knepley 1391475e0ac9SMatthew G. Knepley + dim - the spatial dimension 1392475e0ac9SMatthew G. Knepley . Nf - the number of fields 1393475e0ac9SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1394475e0ac9SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1395475e0ac9SMatthew G. Knepley . u - each field evaluated at the current point 1396475e0ac9SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1397475e0ac9SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1398475e0ac9SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1399475e0ac9SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1400475e0ac9SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1401475e0ac9SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1402475e0ac9SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1403475e0ac9SMatthew G. Knepley . t - current time 1404475e0ac9SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1405475e0ac9SMatthew G. Knepley . x - coordinates of the current point 1406475e0ac9SMatthew G. Knepley - g0 - output values at the current point 1407475e0ac9SMatthew G. Knepley 1408475e0ac9SMatthew G. Knepley Level: intermediate 1409475e0ac9SMatthew G. Knepley 1410475e0ac9SMatthew G. Knepley .seealso: PetscDSGetJacobianPreconditioner(), PetscDSSetJacobian() 1411475e0ac9SMatthew G. Knepley @*/ 1412475e0ac9SMatthew G. Knepley PetscErrorCode PetscDSSetJacobianPreconditioner(PetscDS prob, PetscInt f, PetscInt g, 1413475e0ac9SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1414475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1415475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1416475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]), 1417475e0ac9SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1418475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1419475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1420475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]), 1421475e0ac9SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1422475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1423475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1424475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]), 1425475e0ac9SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1426475e0ac9SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1427475e0ac9SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1428475e0ac9SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[])) 1429475e0ac9SMatthew G. Knepley { 1430475e0ac9SMatthew G. Knepley PetscErrorCode ierr; 1431475e0ac9SMatthew G. Knepley 1432475e0ac9SMatthew G. Knepley PetscFunctionBegin; 1433475e0ac9SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1434475e0ac9SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 1435475e0ac9SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 1436475e0ac9SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 1437475e0ac9SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 1438475e0ac9SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 1439475e0ac9SMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 1440475e0ac9SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 1441475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+0] = g0; 1442475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+1] = g1; 1443475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+2] = g2; 1444475e0ac9SMatthew G. Knepley prob->gp[(f*prob->Nf + g)*4+3] = g3; 1445475e0ac9SMatthew G. Knepley PetscFunctionReturn(0); 1446475e0ac9SMatthew G. Knepley } 1447475e0ac9SMatthew G. Knepley 1448475e0ac9SMatthew G. Knepley #undef __FUNCT__ 1449*b7e05686SMatthew G. Knepley #define __FUNCT__ "PetscDSHasDynamicJacobian" 1450*b7e05686SMatthew G. Knepley /*@C 1451*b7e05686SMatthew G. Knepley PetscDSHasDynamicJacobian - Signals that a dynamic Jacobian, dF/du_t, has been set 1452*b7e05686SMatthew G. Knepley 1453*b7e05686SMatthew G. Knepley Not collective 1454*b7e05686SMatthew G. Knepley 1455*b7e05686SMatthew G. Knepley Input Parameter: 1456*b7e05686SMatthew G. Knepley . prob - The PetscDS 1457*b7e05686SMatthew G. Knepley 1458*b7e05686SMatthew G. Knepley Output Parameter: 1459*b7e05686SMatthew G. Knepley . hasDynJac - flag that pointwise function for dynamic Jacobian has been set 1460*b7e05686SMatthew G. Knepley 1461*b7e05686SMatthew G. Knepley Level: intermediate 1462*b7e05686SMatthew G. Knepley 1463*b7e05686SMatthew G. Knepley .seealso: PetscDSGetDynamicJacobian(), PetscDSSetDynamicJacobian(), PetscDSGetJacobian() 1464*b7e05686SMatthew G. Knepley @*/ 1465*b7e05686SMatthew G. Knepley PetscErrorCode PetscDSHasDynamicJacobian(PetscDS prob, PetscBool *hasDynJac) 1466*b7e05686SMatthew G. Knepley { 1467*b7e05686SMatthew G. Knepley PetscInt f, g, h; 1468*b7e05686SMatthew G. Knepley 1469*b7e05686SMatthew G. Knepley PetscFunctionBegin; 1470*b7e05686SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1471*b7e05686SMatthew G. Knepley *hasDynJac = PETSC_FALSE; 1472*b7e05686SMatthew G. Knepley for (f = 0; f < prob->Nf; ++f) { 1473*b7e05686SMatthew G. Knepley for (g = 0; g < prob->Nf; ++g) { 1474*b7e05686SMatthew G. Knepley for (h = 0; h < 4; ++h) { 1475*b7e05686SMatthew G. Knepley if (prob->gt[(f*prob->Nf + g)*4+h]) *hasDynJac = PETSC_TRUE; 1476*b7e05686SMatthew G. Knepley } 1477*b7e05686SMatthew G. Knepley } 1478*b7e05686SMatthew G. Knepley } 1479*b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1480*b7e05686SMatthew G. Knepley } 1481*b7e05686SMatthew G. Knepley 1482*b7e05686SMatthew G. Knepley #undef __FUNCT__ 1483*b7e05686SMatthew G. Knepley #define __FUNCT__ "PetscDSGetDynamicJacobian" 1484*b7e05686SMatthew G. Knepley /*@C 1485*b7e05686SMatthew G. Knepley PetscDSGetDynamicJacobian - Get the pointwise dynamic Jacobian, dF/du_t, function for given test and basis field 1486*b7e05686SMatthew G. Knepley 1487*b7e05686SMatthew G. Knepley Not collective 1488*b7e05686SMatthew G. Knepley 1489*b7e05686SMatthew G. Knepley Input Parameters: 1490*b7e05686SMatthew G. Knepley + prob - The PetscDS 1491*b7e05686SMatthew G. Knepley . f - The test field number 1492*b7e05686SMatthew G. Knepley - g - The field number 1493*b7e05686SMatthew G. Knepley 1494*b7e05686SMatthew G. Knepley Output Parameters: 1495*b7e05686SMatthew G. Knepley + g0 - integrand for the test and basis function term 1496*b7e05686SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1497*b7e05686SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1498*b7e05686SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1499*b7e05686SMatthew G. Knepley 1500*b7e05686SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1501*b7e05686SMatthew G. Knepley 1502*b7e05686SMatthew 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 1503*b7e05686SMatthew G. Knepley 1504*b7e05686SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1505*b7e05686SMatthew G. Knepley 1506*b7e05686SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1507*b7e05686SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1508*b7e05686SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1509*b7e05686SMatthew G. Knepley $ PetscReal t, const PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]) 1510*b7e05686SMatthew G. Knepley 1511*b7e05686SMatthew G. Knepley + dim - the spatial dimension 1512*b7e05686SMatthew G. Knepley . Nf - the number of fields 1513*b7e05686SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1514*b7e05686SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1515*b7e05686SMatthew G. Knepley . u - each field evaluated at the current point 1516*b7e05686SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1517*b7e05686SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1518*b7e05686SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1519*b7e05686SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1520*b7e05686SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1521*b7e05686SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1522*b7e05686SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1523*b7e05686SMatthew G. Knepley . t - current time 1524*b7e05686SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1525*b7e05686SMatthew G. Knepley . x - coordinates of the current point 1526*b7e05686SMatthew G. Knepley - g0 - output values at the current point 1527*b7e05686SMatthew G. Knepley 1528*b7e05686SMatthew G. Knepley Level: intermediate 1529*b7e05686SMatthew G. Knepley 1530*b7e05686SMatthew G. Knepley .seealso: PetscDSSetJacobian() 1531*b7e05686SMatthew G. Knepley @*/ 1532*b7e05686SMatthew G. Knepley PetscErrorCode PetscDSGetDynamicJacobian(PetscDS prob, PetscInt f, PetscInt g, 1533*b7e05686SMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1534*b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1535*b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1536*b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]), 1537*b7e05686SMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1538*b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1539*b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1540*b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]), 1541*b7e05686SMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1542*b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1543*b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1544*b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]), 1545*b7e05686SMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1546*b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1547*b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1548*b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[])) 1549*b7e05686SMatthew G. Knepley { 1550*b7e05686SMatthew G. Knepley PetscFunctionBegin; 1551*b7e05686SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1552*b7e05686SMatthew 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); 1553*b7e05686SMatthew 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); 1554*b7e05686SMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gt[(f*prob->Nf + g)*4+0];} 1555*b7e05686SMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gt[(f*prob->Nf + g)*4+1];} 1556*b7e05686SMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gt[(f*prob->Nf + g)*4+2];} 1557*b7e05686SMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gt[(f*prob->Nf + g)*4+3];} 1558*b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1559*b7e05686SMatthew G. Knepley } 1560*b7e05686SMatthew G. Knepley 1561*b7e05686SMatthew G. Knepley #undef __FUNCT__ 1562*b7e05686SMatthew G. Knepley #define __FUNCT__ "PetscDSSetDynamicJacobian" 1563*b7e05686SMatthew G. Knepley /*@C 1564*b7e05686SMatthew G. Knepley PetscDSSetDynamicJacobian - Set the pointwise dynamic Jacobian, dF/du_t, function for given test and basis fields 1565*b7e05686SMatthew G. Knepley 1566*b7e05686SMatthew G. Knepley Not collective 1567*b7e05686SMatthew G. Knepley 1568*b7e05686SMatthew G. Knepley Input Parameters: 1569*b7e05686SMatthew G. Knepley + prob - The PetscDS 1570*b7e05686SMatthew G. Knepley . f - The test field number 1571*b7e05686SMatthew G. Knepley . g - The field number 1572*b7e05686SMatthew G. Knepley . g0 - integrand for the test and basis function term 1573*b7e05686SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1574*b7e05686SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1575*b7e05686SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1576*b7e05686SMatthew G. Knepley 1577*b7e05686SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1578*b7e05686SMatthew G. Knepley 1579*b7e05686SMatthew 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 1580*b7e05686SMatthew G. Knepley 1581*b7e05686SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1582*b7e05686SMatthew G. Knepley 1583*b7e05686SMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1584*b7e05686SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1585*b7e05686SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1586*b7e05686SMatthew G. Knepley $ PetscReal t, const PetscReal x[], PetscScalar g0[]) 1587*b7e05686SMatthew G. Knepley 1588*b7e05686SMatthew G. Knepley + dim - the spatial dimension 1589*b7e05686SMatthew G. Knepley . Nf - the number of fields 1590*b7e05686SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1591*b7e05686SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1592*b7e05686SMatthew G. Knepley . u - each field evaluated at the current point 1593*b7e05686SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1594*b7e05686SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1595*b7e05686SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1596*b7e05686SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1597*b7e05686SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1598*b7e05686SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1599*b7e05686SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1600*b7e05686SMatthew G. Knepley . t - current time 1601*b7e05686SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1602*b7e05686SMatthew G. Knepley . x - coordinates of the current point 1603*b7e05686SMatthew G. Knepley - g0 - output values at the current point 1604*b7e05686SMatthew G. Knepley 1605*b7e05686SMatthew G. Knepley Level: intermediate 1606*b7e05686SMatthew G. Knepley 1607*b7e05686SMatthew G. Knepley .seealso: PetscDSGetJacobian() 1608*b7e05686SMatthew G. Knepley @*/ 1609*b7e05686SMatthew G. Knepley PetscErrorCode PetscDSSetDynamicJacobian(PetscDS prob, PetscInt f, PetscInt g, 1610*b7e05686SMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1611*b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1612*b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1613*b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g0[]), 1614*b7e05686SMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1615*b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1616*b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1617*b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g1[]), 1618*b7e05686SMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1619*b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1620*b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1621*b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g2[]), 1622*b7e05686SMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1623*b7e05686SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1624*b7e05686SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 1625*b7e05686SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscScalar g3[])) 1626*b7e05686SMatthew G. Knepley { 1627*b7e05686SMatthew G. Knepley PetscErrorCode ierr; 1628*b7e05686SMatthew G. Knepley 1629*b7e05686SMatthew G. Knepley PetscFunctionBegin; 1630*b7e05686SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 1631*b7e05686SMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 1632*b7e05686SMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 1633*b7e05686SMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 1634*b7e05686SMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 1635*b7e05686SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 1636*b7e05686SMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 1637*b7e05686SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 1638*b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+0] = g0; 1639*b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+1] = g1; 1640*b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+2] = g2; 1641*b7e05686SMatthew G. Knepley prob->gt[(f*prob->Nf + g)*4+3] = g3; 1642*b7e05686SMatthew G. Knepley PetscFunctionReturn(0); 1643*b7e05686SMatthew G. Knepley } 1644*b7e05686SMatthew G. Knepley 1645*b7e05686SMatthew G. Knepley #undef __FUNCT__ 16460c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSGetRiemannSolver" 16470c2f2876SMatthew G. Knepley /*@C 16480c2f2876SMatthew G. Knepley PetscDSGetRiemannSolver - Returns the Riemann solver for the given field 16490c2f2876SMatthew G. Knepley 16500c2f2876SMatthew G. Knepley Not collective 16510c2f2876SMatthew G. Knepley 16520c2f2876SMatthew G. Knepley Input Arguments: 16530c2f2876SMatthew G. Knepley + prob - The PetscDS object 16540c2f2876SMatthew G. Knepley - f - The field number 16550c2f2876SMatthew G. Knepley 16560c2f2876SMatthew G. Knepley Output Argument: 16570c2f2876SMatthew G. Knepley . r - Riemann solver 16580c2f2876SMatthew G. Knepley 16590c2f2876SMatthew G. Knepley Calling sequence for r: 16600c2f2876SMatthew G. Knepley 16615db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 16620c2f2876SMatthew G. Knepley 16635db36cf9SMatthew G. Knepley + dim - The spatial dimension 16645db36cf9SMatthew G. Knepley . Nf - The number of fields 16655db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 16660c2f2876SMatthew G. Knepley . n - The normal vector to the interface 16670c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 16680c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 16690c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 16700c2f2876SMatthew G. Knepley - ctx - optional user context 16710c2f2876SMatthew G. Knepley 16720c2f2876SMatthew G. Knepley Level: intermediate 16730c2f2876SMatthew G. Knepley 16740c2f2876SMatthew G. Knepley .seealso: PetscDSSetRiemannSolver() 16750c2f2876SMatthew G. Knepley @*/ 16760c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetRiemannSolver(PetscDS prob, PetscInt f, 16775db36cf9SMatthew G. Knepley void (**r)(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx)) 16780c2f2876SMatthew G. Knepley { 16790c2f2876SMatthew G. Knepley PetscFunctionBegin; 16800c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 16810c2f2876SMatthew 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); 16820c2f2876SMatthew G. Knepley PetscValidPointer(r, 3); 16830c2f2876SMatthew G. Knepley *r = prob->r[f]; 16840c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 16850c2f2876SMatthew G. Knepley } 16860c2f2876SMatthew G. Knepley 16870c2f2876SMatthew G. Knepley #undef __FUNCT__ 16880c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSSetRiemannSolver" 16890c2f2876SMatthew G. Knepley /*@C 16900c2f2876SMatthew G. Knepley PetscDSSetRiemannSolver - Sets the Riemann solver for the given field 16910c2f2876SMatthew G. Knepley 16920c2f2876SMatthew G. Knepley Not collective 16930c2f2876SMatthew G. Knepley 16940c2f2876SMatthew G. Knepley Input Arguments: 16950c2f2876SMatthew G. Knepley + prob - The PetscDS object 16960c2f2876SMatthew G. Knepley . f - The field number 16970c2f2876SMatthew G. Knepley - r - Riemann solver 16980c2f2876SMatthew G. Knepley 16990c2f2876SMatthew G. Knepley Calling sequence for r: 17000c2f2876SMatthew G. Knepley 17015db36cf9SMatthew G. Knepley $ r(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx) 17020c2f2876SMatthew G. Knepley 17035db36cf9SMatthew G. Knepley + dim - The spatial dimension 17045db36cf9SMatthew G. Knepley . Nf - The number of fields 17055db36cf9SMatthew G. Knepley . x - The coordinates at a point on the interface 17060c2f2876SMatthew G. Knepley . n - The normal vector to the interface 17070c2f2876SMatthew G. Knepley . uL - The state vector to the left of the interface 17080c2f2876SMatthew G. Knepley . uR - The state vector to the right of the interface 17090c2f2876SMatthew G. Knepley . flux - output array of flux through the interface 17100c2f2876SMatthew G. Knepley - ctx - optional user context 17110c2f2876SMatthew G. Knepley 17120c2f2876SMatthew G. Knepley Level: intermediate 17130c2f2876SMatthew G. Knepley 17140c2f2876SMatthew G. Knepley .seealso: PetscDSGetRiemannSolver() 17150c2f2876SMatthew G. Knepley @*/ 17160c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetRiemannSolver(PetscDS prob, PetscInt f, 17175db36cf9SMatthew G. Knepley void (*r)(PetscInt dim, PetscInt Nf, const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx)) 17180c2f2876SMatthew G. Knepley { 17190c2f2876SMatthew G. Knepley PetscErrorCode ierr; 17200c2f2876SMatthew G. Knepley 17210c2f2876SMatthew G. Knepley PetscFunctionBegin; 17220c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 17230c2f2876SMatthew G. Knepley PetscValidFunction(r, 3); 17240c2f2876SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 17250c2f2876SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 17260c2f2876SMatthew G. Knepley prob->r[f] = r; 17270c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 17280c2f2876SMatthew G. Knepley } 17290c2f2876SMatthew G. Knepley 17300c2f2876SMatthew G. Knepley #undef __FUNCT__ 17310c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSGetContext" 17320c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetContext(PetscDS prob, PetscInt f, void **ctx) 17330c2f2876SMatthew G. Knepley { 17340c2f2876SMatthew G. Knepley PetscFunctionBegin; 17350c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 17360c2f2876SMatthew 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); 17370c2f2876SMatthew G. Knepley PetscValidPointer(ctx, 3); 17380c2f2876SMatthew G. Knepley *ctx = prob->ctx[f]; 17390c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 17400c2f2876SMatthew G. Knepley } 17410c2f2876SMatthew G. Knepley 17420c2f2876SMatthew G. Knepley #undef __FUNCT__ 17430c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSSetContext" 17440c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetContext(PetscDS prob, PetscInt f, void *ctx) 17450c2f2876SMatthew G. Knepley { 17460c2f2876SMatthew G. Knepley PetscErrorCode ierr; 17470c2f2876SMatthew G. Knepley 17480c2f2876SMatthew G. Knepley PetscFunctionBegin; 17490c2f2876SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 17500c2f2876SMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 17510c2f2876SMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 17520c2f2876SMatthew G. Knepley prob->ctx[f] = ctx; 17530c2f2876SMatthew G. Knepley PetscFunctionReturn(0); 17540c2f2876SMatthew G. Knepley } 17550c2f2876SMatthew G. Knepley 17560c2f2876SMatthew G. Knepley #undef __FUNCT__ 17572764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdResidual" 1758194d53e6SMatthew G. Knepley /*@C 1759194d53e6SMatthew G. Knepley PetscDSGetBdResidual - Get the pointwise boundary residual function for a given test field 1760194d53e6SMatthew G. Knepley 1761194d53e6SMatthew G. Knepley Not collective 1762194d53e6SMatthew G. Knepley 1763194d53e6SMatthew G. Knepley Input Parameters: 1764194d53e6SMatthew G. Knepley + prob - The PetscDS 1765194d53e6SMatthew G. Knepley - f - The test field number 1766194d53e6SMatthew G. Knepley 1767194d53e6SMatthew G. Knepley Output Parameters: 1768194d53e6SMatthew G. Knepley + f0 - boundary integrand for the test function term 1769194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 1770194d53e6SMatthew G. Knepley 1771194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1772194d53e6SMatthew G. Knepley 1773194d53e6SMatthew 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 1774194d53e6SMatthew G. Knepley 1775194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1776194d53e6SMatthew G. Knepley 177730b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1778194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1779194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 178030b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 1781194d53e6SMatthew G. Knepley 1782194d53e6SMatthew G. Knepley + dim - the spatial dimension 1783194d53e6SMatthew G. Knepley . Nf - the number of fields 1784194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1785194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1786194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1787194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1788194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1789194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1790194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1791194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1792194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1793194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1794194d53e6SMatthew G. Knepley . t - current time 1795194d53e6SMatthew G. Knepley . x - coordinates of the current point 1796194d53e6SMatthew G. Knepley . n - unit normal at the current point 1797194d53e6SMatthew G. Knepley - f0 - output values at the current point 1798194d53e6SMatthew G. Knepley 1799194d53e6SMatthew G. Knepley Level: intermediate 1800194d53e6SMatthew G. Knepley 1801194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdResidual() 1802194d53e6SMatthew G. Knepley @*/ 18032764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdResidual(PetscDS prob, PetscInt f, 180430b9ff8bSMatthew G. Knepley void (**f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1805194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1806194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 180730b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]), 180830b9ff8bSMatthew G. Knepley void (**f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1809194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1810194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 181130b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f1[])) 18122764a2aaSMatthew G. Knepley { 18132764a2aaSMatthew G. Knepley PetscFunctionBegin; 18142764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 18152764a2aaSMatthew 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); 18162764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 3); *f0 = prob->fBd[f*2+0];} 18172764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 4); *f1 = prob->fBd[f*2+1];} 18182764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 18192764a2aaSMatthew G. Knepley } 18202764a2aaSMatthew G. Knepley 18212764a2aaSMatthew G. Knepley #undef __FUNCT__ 18222764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdResidual" 1823194d53e6SMatthew G. Knepley /*@C 1824194d53e6SMatthew G. Knepley PetscDSSetBdResidual - Get the pointwise boundary residual function for a given test field 1825194d53e6SMatthew G. Knepley 1826194d53e6SMatthew G. Knepley Not collective 1827194d53e6SMatthew G. Knepley 1828194d53e6SMatthew G. Knepley Input Parameters: 1829194d53e6SMatthew G. Knepley + prob - The PetscDS 1830194d53e6SMatthew G. Knepley . f - The test field number 1831194d53e6SMatthew G. Knepley . f0 - boundary integrand for the test function term 1832194d53e6SMatthew G. Knepley - f1 - boundary integrand for the test function gradient term 1833194d53e6SMatthew G. Knepley 1834194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1835194d53e6SMatthew G. Knepley 1836194d53e6SMatthew 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 1837194d53e6SMatthew G. Knepley 1838194d53e6SMatthew G. Knepley The calling sequence for the callbacks f0 and f1 is given by: 1839194d53e6SMatthew G. Knepley 184030b9ff8bSMatthew G. Knepley $ f0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1841194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1842194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 184330b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]) 1844194d53e6SMatthew G. Knepley 1845194d53e6SMatthew G. Knepley + dim - the spatial dimension 1846194d53e6SMatthew G. Knepley . Nf - the number of fields 1847194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1848194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1849194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1850194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1851194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1852194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1853194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1854194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1855194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1856194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1857194d53e6SMatthew G. Knepley . t - current time 1858194d53e6SMatthew G. Knepley . x - coordinates of the current point 1859194d53e6SMatthew G. Knepley . n - unit normal at the current point 1860194d53e6SMatthew G. Knepley - f0 - output values at the current point 1861194d53e6SMatthew G. Knepley 1862194d53e6SMatthew G. Knepley Level: intermediate 1863194d53e6SMatthew G. Knepley 1864194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdResidual() 1865194d53e6SMatthew G. Knepley @*/ 18662764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdResidual(PetscDS prob, PetscInt f, 186730b9ff8bSMatthew G. Knepley void (*f0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1868194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1869194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 187030b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f0[]), 187130b9ff8bSMatthew G. Knepley void (*f1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1872194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1873194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 187430b9ff8bSMatthew G. Knepley PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar f1[])) 18752764a2aaSMatthew G. Knepley { 18762764a2aaSMatthew G. Knepley PetscErrorCode ierr; 18772764a2aaSMatthew G. Knepley 18782764a2aaSMatthew G. Knepley PetscFunctionBegin; 18792764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 18802764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 18812764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr); 18822764a2aaSMatthew G. Knepley if (f0) {PetscValidFunction(f0, 3); prob->fBd[f*2+0] = f0;} 18832764a2aaSMatthew G. Knepley if (f1) {PetscValidFunction(f1, 4); prob->fBd[f*2+1] = f1;} 18842764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 18852764a2aaSMatthew G. Knepley } 18862764a2aaSMatthew G. Knepley 18872764a2aaSMatthew G. Knepley #undef __FUNCT__ 18882764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdJacobian" 1889194d53e6SMatthew G. Knepley /*@C 1890194d53e6SMatthew G. Knepley PetscDSGetBdJacobian - Get the pointwise boundary Jacobian function for given test and basis field 1891194d53e6SMatthew G. Knepley 1892194d53e6SMatthew G. Knepley Not collective 1893194d53e6SMatthew G. Knepley 1894194d53e6SMatthew G. Knepley Input Parameters: 1895194d53e6SMatthew G. Knepley + prob - The PetscDS 1896194d53e6SMatthew G. Knepley . f - The test field number 1897194d53e6SMatthew G. Knepley - g - The field number 1898194d53e6SMatthew G. Knepley 1899194d53e6SMatthew G. Knepley Output Parameters: 1900194d53e6SMatthew G. Knepley + g0 - integrand for the test and basis function term 1901194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1902194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1903194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1904194d53e6SMatthew G. Knepley 1905194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1906194d53e6SMatthew G. Knepley 1907194d53e6SMatthew 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 1908194d53e6SMatthew G. Knepley 1909194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1910194d53e6SMatthew G. Knepley 191130b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1912194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1913194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 191430b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 1915194d53e6SMatthew G. Knepley 1916194d53e6SMatthew G. Knepley + dim - the spatial dimension 1917194d53e6SMatthew G. Knepley . Nf - the number of fields 1918194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1919194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1920194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1921194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 1922194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 1923194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 1924194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 1925194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 1926194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 1927194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 1928194d53e6SMatthew G. Knepley . t - current time 19292aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 1930194d53e6SMatthew G. Knepley . x - coordinates of the current point 1931194d53e6SMatthew G. Knepley . n - normal at the current point 1932194d53e6SMatthew G. Knepley - g0 - output values at the current point 1933194d53e6SMatthew G. Knepley 1934194d53e6SMatthew G. Knepley Level: intermediate 1935194d53e6SMatthew G. Knepley 1936194d53e6SMatthew G. Knepley .seealso: PetscDSSetBdJacobian() 1937194d53e6SMatthew G. Knepley @*/ 19382764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdJacobian(PetscDS prob, PetscInt f, PetscInt g, 193930b9ff8bSMatthew G. Knepley void (**g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1940194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1941194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 19422aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g0[]), 194330b9ff8bSMatthew G. Knepley void (**g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1944194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1945194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 19462aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g1[]), 194730b9ff8bSMatthew G. Knepley void (**g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1948194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1949194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 19502aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g2[]), 195130b9ff8bSMatthew G. Knepley void (**g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1952194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1953194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 19542aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g3[])) 19552764a2aaSMatthew G. Knepley { 19562764a2aaSMatthew G. Knepley PetscFunctionBegin; 19572764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 19582764a2aaSMatthew 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); 19592764a2aaSMatthew 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); 19602764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gBd[(f*prob->Nf + g)*4+0];} 19612764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gBd[(f*prob->Nf + g)*4+1];} 19622764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gBd[(f*prob->Nf + g)*4+2];} 19632764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gBd[(f*prob->Nf + g)*4+3];} 19642764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 19652764a2aaSMatthew G. Knepley } 19662764a2aaSMatthew G. Knepley 19672764a2aaSMatthew G. Knepley #undef __FUNCT__ 19682764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdJacobian" 1969194d53e6SMatthew G. Knepley /*@C 1970194d53e6SMatthew G. Knepley PetscDSSetBdJacobian - Set the pointwise boundary Jacobian function for given test and basis field 1971194d53e6SMatthew G. Knepley 1972194d53e6SMatthew G. Knepley Not collective 1973194d53e6SMatthew G. Knepley 1974194d53e6SMatthew G. Knepley Input Parameters: 1975194d53e6SMatthew G. Knepley + prob - The PetscDS 1976194d53e6SMatthew G. Knepley . f - The test field number 1977194d53e6SMatthew G. Knepley . g - The field number 1978194d53e6SMatthew G. Knepley . g0 - integrand for the test and basis function term 1979194d53e6SMatthew G. Knepley . g1 - integrand for the test function and basis function gradient term 1980194d53e6SMatthew G. Knepley . g2 - integrand for the test function gradient and basis function term 1981194d53e6SMatthew G. Knepley - g3 - integrand for the test function gradient and basis function gradient term 1982194d53e6SMatthew G. Knepley 1983194d53e6SMatthew G. Knepley Note: We are using a first order FEM model for the weak form: 1984194d53e6SMatthew G. Knepley 1985194d53e6SMatthew 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 1986194d53e6SMatthew G. Knepley 1987194d53e6SMatthew G. Knepley The calling sequence for the callbacks g0, g1, g2 and g3 is given by: 1988194d53e6SMatthew G. Knepley 198930b9ff8bSMatthew G. Knepley $ g0(PetscInt dim, PetscInt Nf, PetscInt NfAux, 1990194d53e6SMatthew G. Knepley $ const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 1991194d53e6SMatthew G. Knepley $ const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 199230b9ff8bSMatthew G. Knepley $ PetscReal t, const PetscReal x[], const PetscReal n[], PetscScalar g0[]) 1993194d53e6SMatthew G. Knepley 1994194d53e6SMatthew G. Knepley + dim - the spatial dimension 1995194d53e6SMatthew G. Knepley . Nf - the number of fields 1996194d53e6SMatthew G. Knepley . uOff - the offset into u[] and u_t[] for each field 1997194d53e6SMatthew G. Knepley . uOff_x - the offset into u_x[] for each field 1998194d53e6SMatthew G. Knepley . u - each field evaluated at the current point 1999194d53e6SMatthew G. Knepley . u_t - the time derivative of each field evaluated at the current point 2000194d53e6SMatthew G. Knepley . u_x - the gradient of each field evaluated at the current point 2001194d53e6SMatthew G. Knepley . aOff - the offset into a[] and a_t[] for each auxiliary field 2002194d53e6SMatthew G. Knepley . aOff_x - the offset into a_x[] for each auxiliary field 2003194d53e6SMatthew G. Knepley . a - each auxiliary field evaluated at the current point 2004194d53e6SMatthew G. Knepley . a_t - the time derivative of each auxiliary field evaluated at the current point 2005194d53e6SMatthew G. Knepley . a_x - the gradient of auxiliary each field evaluated at the current point 2006194d53e6SMatthew G. Knepley . t - current time 20072aa1fc23SMatthew G. Knepley . u_tShift - the multiplier a for dF/dU_t 2008194d53e6SMatthew G. Knepley . x - coordinates of the current point 2009194d53e6SMatthew G. Knepley . n - normal at the current point 2010194d53e6SMatthew G. Knepley - g0 - output values at the current point 2011194d53e6SMatthew G. Knepley 2012194d53e6SMatthew G. Knepley Level: intermediate 2013194d53e6SMatthew G. Knepley 2014194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdJacobian() 2015194d53e6SMatthew G. Knepley @*/ 20162764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdJacobian(PetscDS prob, PetscInt f, PetscInt g, 201730b9ff8bSMatthew G. Knepley void (*g0)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2018194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2019194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 20202aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g0[]), 202130b9ff8bSMatthew G. Knepley void (*g1)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2022194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2023194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 20242aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g1[]), 202530b9ff8bSMatthew G. Knepley void (*g2)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2026194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2027194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 20282aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g2[]), 202930b9ff8bSMatthew G. Knepley void (*g3)(PetscInt dim, PetscInt Nf, PetscInt NfAux, 2030194d53e6SMatthew G. Knepley const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], 2031194d53e6SMatthew G. Knepley const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], 20322aa1fc23SMatthew G. Knepley PetscReal t, PetscReal u_tShift, const PetscReal x[], const PetscReal n[], PetscScalar g3[])) 20332764a2aaSMatthew G. Knepley { 20342764a2aaSMatthew G. Knepley PetscErrorCode ierr; 20352764a2aaSMatthew G. Knepley 20362764a2aaSMatthew G. Knepley PetscFunctionBegin; 20372764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 20382764a2aaSMatthew G. Knepley if (g0) PetscValidFunction(g0, 4); 20392764a2aaSMatthew G. Knepley if (g1) PetscValidFunction(g1, 5); 20402764a2aaSMatthew G. Knepley if (g2) PetscValidFunction(g2, 6); 20412764a2aaSMatthew G. Knepley if (g3) PetscValidFunction(g3, 7); 20422764a2aaSMatthew G. Knepley if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f); 20432764a2aaSMatthew G. Knepley if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g); 20442764a2aaSMatthew G. Knepley ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr); 20452764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+0] = g0; 20462764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+1] = g1; 20472764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+2] = g2; 20482764a2aaSMatthew G. Knepley prob->gBd[(f*prob->Nf + g)*4+3] = g3; 20492764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 20502764a2aaSMatthew G. Knepley } 20512764a2aaSMatthew G. Knepley 20522764a2aaSMatthew G. Knepley #undef __FUNCT__ 20532764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetFieldOffset" 2054bc4ae4beSMatthew G. Knepley /*@ 2055bc4ae4beSMatthew G. Knepley PetscDSGetFieldOffset - Returns the offset of the given field in the full space basis 2056bc4ae4beSMatthew G. Knepley 2057bc4ae4beSMatthew G. Knepley Not collective 2058bc4ae4beSMatthew G. Knepley 2059bc4ae4beSMatthew G. Knepley Input Parameters: 2060bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 2061bc4ae4beSMatthew G. Knepley - f - The field number 2062bc4ae4beSMatthew G. Knepley 2063bc4ae4beSMatthew G. Knepley Output Parameter: 2064bc4ae4beSMatthew G. Knepley . off - The offset 2065bc4ae4beSMatthew G. Knepley 2066bc4ae4beSMatthew G. Knepley Level: beginner 2067bc4ae4beSMatthew G. Knepley 2068bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 2069bc4ae4beSMatthew G. Knepley @*/ 20702764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetFieldOffset(PetscDS prob, PetscInt f, PetscInt *off) 20712764a2aaSMatthew G. Knepley { 20722764a2aaSMatthew G. Knepley PetscInt g; 20732764a2aaSMatthew G. Knepley PetscErrorCode ierr; 20742764a2aaSMatthew G. Knepley 20752764a2aaSMatthew G. Knepley PetscFunctionBegin; 20762764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 20772764a2aaSMatthew G. Knepley PetscValidPointer(off, 3); 20782764a2aaSMatthew 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); 20792764a2aaSMatthew G. Knepley *off = 0; 20802764a2aaSMatthew G. Knepley for (g = 0; g < f; ++g) { 20812764a2aaSMatthew G. Knepley PetscFE fe = (PetscFE) prob->disc[g]; 20822764a2aaSMatthew G. Knepley PetscInt Nb, Nc; 20832764a2aaSMatthew G. Knepley 20842764a2aaSMatthew G. Knepley ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr); 20852764a2aaSMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 20862764a2aaSMatthew G. Knepley *off += Nb*Nc; 20872764a2aaSMatthew G. Knepley } 20882764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 20892764a2aaSMatthew G. Knepley } 20902764a2aaSMatthew G. Knepley 20912764a2aaSMatthew G. Knepley #undef __FUNCT__ 20922764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdFieldOffset" 2093bc4ae4beSMatthew G. Knepley /*@ 2094c3ac4435SMatthew G. Knepley PetscDSGetBdFieldOffset - Returns the offset of the given field in the full space boundary basis 2095bc4ae4beSMatthew G. Knepley 2096bc4ae4beSMatthew G. Knepley Not collective 2097bc4ae4beSMatthew G. Knepley 2098bc4ae4beSMatthew G. Knepley Input Parameters: 2099bc4ae4beSMatthew G. Knepley + prob - The PetscDS object 2100bc4ae4beSMatthew G. Knepley - f - The field number 2101bc4ae4beSMatthew G. Knepley 2102bc4ae4beSMatthew G. Knepley Output Parameter: 2103bc4ae4beSMatthew G. Knepley . off - The boundary offset 2104bc4ae4beSMatthew G. Knepley 2105bc4ae4beSMatthew G. Knepley Level: beginner 2106bc4ae4beSMatthew G. Knepley 2107bc4ae4beSMatthew G. Knepley .seealso: PetscDSGetFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 2108bc4ae4beSMatthew G. Knepley @*/ 21092764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdFieldOffset(PetscDS prob, PetscInt f, PetscInt *off) 21102764a2aaSMatthew G. Knepley { 21112764a2aaSMatthew G. Knepley PetscInt g; 21122764a2aaSMatthew G. Knepley PetscErrorCode ierr; 21132764a2aaSMatthew G. Knepley 21142764a2aaSMatthew G. Knepley PetscFunctionBegin; 21152764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 21162764a2aaSMatthew G. Knepley PetscValidPointer(off, 3); 21172764a2aaSMatthew 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); 21182764a2aaSMatthew G. Knepley *off = 0; 21192764a2aaSMatthew G. Knepley for (g = 0; g < f; ++g) { 21202764a2aaSMatthew G. Knepley PetscFE fe = (PetscFE) prob->discBd[g]; 21212764a2aaSMatthew G. Knepley PetscInt Nb, Nc; 21222764a2aaSMatthew G. Knepley 21232764a2aaSMatthew G. Knepley ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr); 21242764a2aaSMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 21252764a2aaSMatthew G. Knepley *off += Nb*Nc; 21266ce16762SMatthew G. Knepley } 21276ce16762SMatthew G. Knepley PetscFunctionReturn(0); 21286ce16762SMatthew G. Knepley } 21296ce16762SMatthew G. Knepley 21306ce16762SMatthew G. Knepley #undef __FUNCT__ 21316ce16762SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentOffset" 21326ce16762SMatthew G. Knepley /*@ 21336ce16762SMatthew G. Knepley PetscDSGetComponentOffset - Returns the offset of the given field on an evaluation point 21346ce16762SMatthew G. Knepley 21356ce16762SMatthew G. Knepley Not collective 21366ce16762SMatthew G. Knepley 21376ce16762SMatthew G. Knepley Input Parameters: 21386ce16762SMatthew G. Knepley + prob - The PetscDS object 21396ce16762SMatthew G. Knepley - f - The field number 21406ce16762SMatthew G. Knepley 21416ce16762SMatthew G. Knepley Output Parameter: 21426ce16762SMatthew G. Knepley . off - The offset 21436ce16762SMatthew G. Knepley 21446ce16762SMatthew G. Knepley Level: beginner 21456ce16762SMatthew G. Knepley 21466ce16762SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 21476ce16762SMatthew G. Knepley @*/ 21486ce16762SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffset(PetscDS prob, PetscInt f, PetscInt *off) 21496ce16762SMatthew G. Knepley { 21506ce16762SMatthew G. Knepley PetscInt g; 21516ce16762SMatthew G. Knepley PetscErrorCode ierr; 21526ce16762SMatthew G. Knepley 21536ce16762SMatthew G. Knepley PetscFunctionBegin; 21546ce16762SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 21556ce16762SMatthew G. Knepley PetscValidPointer(off, 3); 21566ce16762SMatthew 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); 21576ce16762SMatthew G. Knepley *off = 0; 21586ce16762SMatthew G. Knepley for (g = 0; g < f; ++g) { 21596ce16762SMatthew G. Knepley PetscFE fe = (PetscFE) prob->disc[g]; 21606ce16762SMatthew G. Knepley PetscInt Nc; 21616ce16762SMatthew G. Knepley 21626ce16762SMatthew G. Knepley ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr); 21636ce16762SMatthew G. Knepley *off += Nc; 21642764a2aaSMatthew G. Knepley } 21652764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 21662764a2aaSMatthew G. Knepley } 21672764a2aaSMatthew G. Knepley 21682764a2aaSMatthew G. Knepley #undef __FUNCT__ 2169194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentOffsets" 2170194d53e6SMatthew G. Knepley /*@ 2171194d53e6SMatthew G. Knepley PetscDSGetComponentOffsets - Returns the offset of each field on an evaluation point 2172194d53e6SMatthew G. Knepley 2173194d53e6SMatthew G. Knepley Not collective 2174194d53e6SMatthew G. Knepley 2175194d53e6SMatthew G. Knepley Input Parameter: 2176194d53e6SMatthew G. Knepley . prob - The PetscDS object 2177194d53e6SMatthew G. Knepley 2178194d53e6SMatthew G. Knepley Output Parameter: 2179194d53e6SMatthew G. Knepley . offsets - The offsets 2180194d53e6SMatthew G. Knepley 2181194d53e6SMatthew G. Knepley Level: beginner 2182194d53e6SMatthew G. Knepley 2183194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 2184194d53e6SMatthew G. Knepley @*/ 2185194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentOffsets(PetscDS prob, PetscInt *offsets[]) 2186194d53e6SMatthew G. Knepley { 2187194d53e6SMatthew G. Knepley PetscFunctionBegin; 2188194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2189194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 2190194d53e6SMatthew G. Knepley *offsets = prob->off; 2191194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 2192194d53e6SMatthew G. Knepley } 2193194d53e6SMatthew G. Knepley 2194194d53e6SMatthew G. Knepley #undef __FUNCT__ 2195194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentDerivativeOffsets" 2196194d53e6SMatthew G. Knepley /*@ 2197194d53e6SMatthew G. Knepley PetscDSGetComponentDerivativeOffsets - Returns the offset of each field derivative on an evaluation point 2198194d53e6SMatthew G. Knepley 2199194d53e6SMatthew G. Knepley Not collective 2200194d53e6SMatthew G. Knepley 2201194d53e6SMatthew G. Knepley Input Parameter: 2202194d53e6SMatthew G. Knepley . prob - The PetscDS object 2203194d53e6SMatthew G. Knepley 2204194d53e6SMatthew G. Knepley Output Parameter: 2205194d53e6SMatthew G. Knepley . offsets - The offsets 2206194d53e6SMatthew G. Knepley 2207194d53e6SMatthew G. Knepley Level: beginner 2208194d53e6SMatthew G. Knepley 2209194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 2210194d53e6SMatthew G. Knepley @*/ 2211194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentDerivativeOffsets(PetscDS prob, PetscInt *offsets[]) 2212194d53e6SMatthew G. Knepley { 2213194d53e6SMatthew G. Knepley PetscFunctionBegin; 2214194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2215194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 2216194d53e6SMatthew G. Knepley *offsets = prob->offDer; 2217194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 2218194d53e6SMatthew G. Knepley } 2219194d53e6SMatthew G. Knepley 2220194d53e6SMatthew G. Knepley #undef __FUNCT__ 2221194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentBdOffsets" 2222194d53e6SMatthew G. Knepley /*@ 2223194d53e6SMatthew G. Knepley PetscDSGetComponentBdOffsets - Returns the offset of each field on a boundary evaluation point 2224194d53e6SMatthew G. Knepley 2225194d53e6SMatthew G. Knepley Not collective 2226194d53e6SMatthew G. Knepley 2227194d53e6SMatthew G. Knepley Input Parameter: 2228194d53e6SMatthew G. Knepley . prob - The PetscDS object 2229194d53e6SMatthew G. Knepley 2230194d53e6SMatthew G. Knepley Output Parameter: 2231194d53e6SMatthew G. Knepley . offsets - The offsets 2232194d53e6SMatthew G. Knepley 2233194d53e6SMatthew G. Knepley Level: beginner 2234194d53e6SMatthew G. Knepley 2235194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 2236194d53e6SMatthew G. Knepley @*/ 2237194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentBdOffsets(PetscDS prob, PetscInt *offsets[]) 2238194d53e6SMatthew G. Knepley { 2239194d53e6SMatthew G. Knepley PetscFunctionBegin; 2240194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2241194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 2242194d53e6SMatthew G. Knepley *offsets = prob->offBd; 2243194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 2244194d53e6SMatthew G. Knepley } 2245194d53e6SMatthew G. Knepley 2246194d53e6SMatthew G. Knepley #undef __FUNCT__ 2247194d53e6SMatthew G. Knepley #define __FUNCT__ "PetscDSGetComponentBdDerivativeOffsets" 2248194d53e6SMatthew G. Knepley /*@ 2249194d53e6SMatthew G. Knepley PetscDSGetComponentBdDerivativeOffsets - Returns the offset of each field derivative on a boundary evaluation point 2250194d53e6SMatthew G. Knepley 2251194d53e6SMatthew G. Knepley Not collective 2252194d53e6SMatthew G. Knepley 2253194d53e6SMatthew G. Knepley Input Parameter: 2254194d53e6SMatthew G. Knepley . prob - The PetscDS object 2255194d53e6SMatthew G. Knepley 2256194d53e6SMatthew G. Knepley Output Parameter: 2257194d53e6SMatthew G. Knepley . offsets - The offsets 2258194d53e6SMatthew G. Knepley 2259194d53e6SMatthew G. Knepley Level: beginner 2260194d53e6SMatthew G. Knepley 2261194d53e6SMatthew G. Knepley .seealso: PetscDSGetBdFieldOffset(), PetscDSGetNumFields(), PetscDSCreate() 2262194d53e6SMatthew G. Knepley @*/ 2263194d53e6SMatthew G. Knepley PetscErrorCode PetscDSGetComponentBdDerivativeOffsets(PetscDS prob, PetscInt *offsets[]) 2264194d53e6SMatthew G. Knepley { 2265194d53e6SMatthew G. Knepley PetscFunctionBegin; 2266194d53e6SMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2267194d53e6SMatthew G. Knepley PetscValidPointer(offsets, 2); 2268194d53e6SMatthew G. Knepley *offsets = prob->offDerBd; 2269194d53e6SMatthew G. Knepley PetscFunctionReturn(0); 2270194d53e6SMatthew G. Knepley } 2271194d53e6SMatthew G. Knepley 2272194d53e6SMatthew G. Knepley #undef __FUNCT__ 22732764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTabulation" 227468c9edb9SMatthew G. Knepley /*@C 227568c9edb9SMatthew G. Knepley PetscDSGetTabulation - Return the basis tabulation at quadrature points for the volume discretization 227668c9edb9SMatthew G. Knepley 227768c9edb9SMatthew G. Knepley Not collective 227868c9edb9SMatthew G. Knepley 227968c9edb9SMatthew G. Knepley Input Parameter: 228068c9edb9SMatthew G. Knepley . prob - The PetscDS object 228168c9edb9SMatthew G. Knepley 228268c9edb9SMatthew G. Knepley Output Parameters: 228368c9edb9SMatthew G. Knepley + basis - The basis function tabulation at quadrature points 228468c9edb9SMatthew G. Knepley - basisDer - The basis function derivative tabulation at quadrature points 228568c9edb9SMatthew G. Knepley 228668c9edb9SMatthew G. Knepley Level: intermediate 228768c9edb9SMatthew G. Knepley 228868c9edb9SMatthew G. Knepley .seealso: PetscDSGetBdTabulation(), PetscDSCreate() 228968c9edb9SMatthew G. Knepley @*/ 22902764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTabulation(PetscDS prob, PetscReal ***basis, PetscReal ***basisDer) 22912764a2aaSMatthew G. Knepley { 22922764a2aaSMatthew G. Knepley PetscErrorCode ierr; 22932764a2aaSMatthew G. Knepley 22942764a2aaSMatthew G. Knepley PetscFunctionBegin; 22952764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 22962764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 22972764a2aaSMatthew G. Knepley if (basis) {PetscValidPointer(basis, 2); *basis = prob->basis;} 22982764a2aaSMatthew G. Knepley if (basisDer) {PetscValidPointer(basisDer, 3); *basisDer = prob->basisDer;} 22992764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 23002764a2aaSMatthew G. Knepley } 23012764a2aaSMatthew G. Knepley 23022764a2aaSMatthew G. Knepley #undef __FUNCT__ 23032764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdTabulation" 230468c9edb9SMatthew G. Knepley /*@C 230568c9edb9SMatthew G. Knepley PetscDSGetBdTabulation - Return the basis tabulation at quadrature points for the boundary discretization 230668c9edb9SMatthew G. Knepley 230768c9edb9SMatthew G. Knepley Not collective 230868c9edb9SMatthew G. Knepley 230968c9edb9SMatthew G. Knepley Input Parameter: 231068c9edb9SMatthew G. Knepley . prob - The PetscDS object 231168c9edb9SMatthew G. Knepley 231268c9edb9SMatthew G. Knepley Output Parameters: 231368c9edb9SMatthew G. Knepley + basis - The basis function tabulation at quadrature points 231468c9edb9SMatthew G. Knepley - basisDer - The basis function derivative tabulation at quadrature points 231568c9edb9SMatthew G. Knepley 231668c9edb9SMatthew G. Knepley Level: intermediate 231768c9edb9SMatthew G. Knepley 231868c9edb9SMatthew G. Knepley .seealso: PetscDSGetTabulation(), PetscDSCreate() 231968c9edb9SMatthew G. Knepley @*/ 23202764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdTabulation(PetscDS prob, PetscReal ***basis, PetscReal ***basisDer) 23212764a2aaSMatthew G. Knepley { 23222764a2aaSMatthew G. Knepley PetscErrorCode ierr; 23232764a2aaSMatthew G. Knepley 23242764a2aaSMatthew G. Knepley PetscFunctionBegin; 23252764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 23262764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 23272764a2aaSMatthew G. Knepley if (basis) {PetscValidPointer(basis, 2); *basis = prob->basisBd;} 23282764a2aaSMatthew G. Knepley if (basisDer) {PetscValidPointer(basisDer, 3); *basisDer = prob->basisDerBd;} 23292764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 23302764a2aaSMatthew G. Knepley } 23312764a2aaSMatthew G. Knepley 23322764a2aaSMatthew G. Knepley #undef __FUNCT__ 23332764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetEvaluationArrays" 23342764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetEvaluationArrays(PetscDS prob, PetscScalar **u, PetscScalar **u_t, PetscScalar **u_x) 23352764a2aaSMatthew G. Knepley { 23362764a2aaSMatthew G. Knepley PetscErrorCode ierr; 23372764a2aaSMatthew G. Knepley 23382764a2aaSMatthew G. Knepley PetscFunctionBegin; 23392764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 23402764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 23412764a2aaSMatthew G. Knepley if (u) {PetscValidPointer(u, 2); *u = prob->u;} 23422764a2aaSMatthew G. Knepley if (u_t) {PetscValidPointer(u_t, 3); *u_t = prob->u_t;} 23432764a2aaSMatthew G. Knepley if (u_x) {PetscValidPointer(u_x, 4); *u_x = prob->u_x;} 23442764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 23452764a2aaSMatthew G. Knepley } 23462764a2aaSMatthew G. Knepley 23472764a2aaSMatthew G. Knepley #undef __FUNCT__ 23482764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetWeakFormArrays" 23492764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetWeakFormArrays(PetscDS prob, PetscScalar **f0, PetscScalar **f1, PetscScalar **g0, PetscScalar **g1, PetscScalar **g2, PetscScalar **g3) 23502764a2aaSMatthew G. Knepley { 23512764a2aaSMatthew G. Knepley PetscErrorCode ierr; 23522764a2aaSMatthew G. Knepley 23532764a2aaSMatthew G. Knepley PetscFunctionBegin; 23542764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 23552764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 23562764a2aaSMatthew G. Knepley if (f0) {PetscValidPointer(f0, 2); *f0 = prob->f0;} 23572764a2aaSMatthew G. Knepley if (f1) {PetscValidPointer(f1, 3); *f1 = prob->f1;} 23582764a2aaSMatthew G. Knepley if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g0;} 23592764a2aaSMatthew G. Knepley if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g1;} 23602764a2aaSMatthew G. Knepley if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g2;} 23612764a2aaSMatthew G. Knepley if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g3;} 23622764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 23632764a2aaSMatthew G. Knepley } 23642764a2aaSMatthew G. Knepley 23652764a2aaSMatthew G. Knepley #undef __FUNCT__ 23662764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetRefCoordArrays" 23672764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetRefCoordArrays(PetscDS prob, PetscReal **x, PetscScalar **refSpaceDer) 23682764a2aaSMatthew G. Knepley { 23692764a2aaSMatthew G. Knepley PetscErrorCode ierr; 23702764a2aaSMatthew G. Knepley 23712764a2aaSMatthew G. Knepley PetscFunctionBegin; 23722764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 23732764a2aaSMatthew G. Knepley ierr = PetscDSSetUp(prob);CHKERRQ(ierr); 23742764a2aaSMatthew G. Knepley if (x) {PetscValidPointer(x, 2); *x = prob->x;} 23752764a2aaSMatthew G. Knepley if (refSpaceDer) {PetscValidPointer(refSpaceDer, 3); *refSpaceDer = prob->refSpaceDer;} 23762764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 23772764a2aaSMatthew G. Knepley } 23782764a2aaSMatthew G. Knepley 23792764a2aaSMatthew G. Knepley #undef __FUNCT__ 2380da51fcedSMatthew G. Knepley #define __FUNCT__ "PetscDSCopyEquations" 2381da51fcedSMatthew G. Knepley /*@ 2382da51fcedSMatthew G. Knepley PetscDSCopyEquations - Copy all pointwise function pointers to the new problem 2383da51fcedSMatthew G. Knepley 2384da51fcedSMatthew G. Knepley Not collective 2385da51fcedSMatthew G. Knepley 2386da51fcedSMatthew G. Knepley Input Parameter: 2387da51fcedSMatthew G. Knepley . prob - The PetscDS object 2388da51fcedSMatthew G. Knepley 2389da51fcedSMatthew G. Knepley Output Parameter: 2390da51fcedSMatthew G. Knepley . newprob - The PetscDS copy 2391da51fcedSMatthew G. Knepley 2392da51fcedSMatthew G. Knepley Level: intermediate 2393da51fcedSMatthew G. Knepley 2394da51fcedSMatthew G. Knepley .seealso: PetscDSSetResidual(), PetscDSSetJacobian(), PetscDSSetRiemannSolver(), PetscDSSetBdResidual(), PetscDSSetBdJacobian(), PetscDSCreate() 2395da51fcedSMatthew G. Knepley @*/ 2396da51fcedSMatthew G. Knepley PetscErrorCode PetscDSCopyEquations(PetscDS prob, PetscDS newprob) 2397da51fcedSMatthew G. Knepley { 2398da51fcedSMatthew G. Knepley PetscInt Nf, Ng, f, g; 2399da51fcedSMatthew G. Knepley PetscErrorCode ierr; 2400da51fcedSMatthew G. Knepley 2401da51fcedSMatthew G. Knepley PetscFunctionBegin; 2402da51fcedSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1); 2403da51fcedSMatthew G. Knepley PetscValidHeaderSpecific(newprob, PETSCDS_CLASSID, 2); 2404da51fcedSMatthew G. Knepley ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr); 2405da51fcedSMatthew G. Knepley ierr = PetscDSGetNumFields(newprob, &Ng);CHKERRQ(ierr); 2406da51fcedSMatthew G. Knepley if (Nf != Ng) SETERRQ2(PetscObjectComm((PetscObject) prob), PETSC_ERR_ARG_SIZ, "Number of fields must match %D != %D", Nf, Ng);CHKERRQ(ierr); 2407da51fcedSMatthew G. Knepley for (f = 0; f < Nf; ++f) { 2408da51fcedSMatthew G. Knepley PetscPointFunc obj; 2409da51fcedSMatthew G. Knepley PetscPointFunc f0, f1; 2410da51fcedSMatthew G. Knepley PetscPointJac g0, g1, g2, g3; 2411da51fcedSMatthew G. Knepley PetscBdPointFunc f0Bd, f1Bd; 2412da51fcedSMatthew G. Knepley PetscBdPointJac g0Bd, g1Bd, g2Bd, g3Bd; 2413da51fcedSMatthew G. Knepley PetscRiemannFunc r; 2414da51fcedSMatthew G. Knepley 2415da51fcedSMatthew G. Knepley ierr = PetscDSGetObjective(prob, f, &obj);CHKERRQ(ierr); 2416da51fcedSMatthew G. Knepley ierr = PetscDSGetResidual(prob, f, &f0, &f1);CHKERRQ(ierr); 2417da51fcedSMatthew G. Knepley ierr = PetscDSGetBdResidual(prob, f, &f0Bd, &f1Bd);CHKERRQ(ierr); 2418da51fcedSMatthew G. Knepley ierr = PetscDSGetRiemannSolver(prob, f, &r);CHKERRQ(ierr); 2419da51fcedSMatthew G. Knepley ierr = PetscDSSetObjective(newprob, f, obj);CHKERRQ(ierr); 2420da51fcedSMatthew G. Knepley ierr = PetscDSSetResidual(newprob, f, f0, f1);CHKERRQ(ierr); 2421da51fcedSMatthew G. Knepley ierr = PetscDSSetBdResidual(newprob, f, f0Bd, f1Bd);CHKERRQ(ierr); 2422da51fcedSMatthew G. Knepley ierr = PetscDSSetRiemannSolver(newprob, f, r);CHKERRQ(ierr); 2423da51fcedSMatthew G. Knepley for (g = 0; g < Nf; ++g) { 2424da51fcedSMatthew G. Knepley ierr = PetscDSGetJacobian(prob, f, g, &g0, &g1, &g2, &g3);CHKERRQ(ierr); 2425da51fcedSMatthew G. Knepley ierr = PetscDSGetBdJacobian(prob, f, g, &g0Bd, &g1Bd, &g2Bd, &g3Bd);CHKERRQ(ierr); 2426da51fcedSMatthew G. Knepley ierr = PetscDSSetJacobian(newprob, f, g, g0, g1, g2, g3);CHKERRQ(ierr); 2427da51fcedSMatthew G. Knepley ierr = PetscDSSetBdJacobian(newprob, f, g, g0Bd, g1Bd, g2Bd, g3Bd);CHKERRQ(ierr); 2428da51fcedSMatthew G. Knepley } 2429da51fcedSMatthew G. Knepley } 2430da51fcedSMatthew G. Knepley PetscFunctionReturn(0); 2431da51fcedSMatthew G. Knepley } 2432da51fcedSMatthew G. Knepley 2433da51fcedSMatthew G. Knepley #undef __FUNCT__ 24342764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroy_Basic" 2435bc4ae4beSMatthew G. Knepley static PetscErrorCode PetscDSDestroy_Basic(PetscDS prob) 24362764a2aaSMatthew G. Knepley { 24372764a2aaSMatthew G. Knepley PetscFunctionBegin; 24382764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 24392764a2aaSMatthew G. Knepley } 24402764a2aaSMatthew G. Knepley 24412764a2aaSMatthew G. Knepley #undef __FUNCT__ 24422764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSInitialize_Basic" 2443bc4ae4beSMatthew G. Knepley static PetscErrorCode PetscDSInitialize_Basic(PetscDS prob) 24442764a2aaSMatthew G. Knepley { 24452764a2aaSMatthew G. Knepley PetscFunctionBegin; 24462764a2aaSMatthew G. Knepley prob->ops->setfromoptions = NULL; 24472764a2aaSMatthew G. Knepley prob->ops->setup = NULL; 24482764a2aaSMatthew G. Knepley prob->ops->view = NULL; 24492764a2aaSMatthew G. Knepley prob->ops->destroy = PetscDSDestroy_Basic; 24502764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 24512764a2aaSMatthew G. Knepley } 24522764a2aaSMatthew G. Knepley 24532764a2aaSMatthew G. Knepley /*MC 24542764a2aaSMatthew G. Knepley PETSCDSBASIC = "basic" - A discrete system with pointwise residual and boundary residual functions 24552764a2aaSMatthew G. Knepley 24562764a2aaSMatthew G. Knepley Level: intermediate 24572764a2aaSMatthew G. Knepley 24582764a2aaSMatthew G. Knepley .seealso: PetscDSType, PetscDSCreate(), PetscDSSetType() 24592764a2aaSMatthew G. Knepley M*/ 24602764a2aaSMatthew G. Knepley 24612764a2aaSMatthew G. Knepley #undef __FUNCT__ 24622764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSCreate_Basic" 24632764a2aaSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscDSCreate_Basic(PetscDS prob) 24642764a2aaSMatthew G. Knepley { 24652764a2aaSMatthew G. Knepley PetscDS_Basic *b; 24662764a2aaSMatthew G. Knepley PetscErrorCode ierr; 24672764a2aaSMatthew G. Knepley 24682764a2aaSMatthew G. Knepley PetscFunctionBegin; 24692764a2aaSMatthew G. Knepley PetscValidHeaderSpecific(prob, PETSCSPACE_CLASSID, 1); 24702764a2aaSMatthew G. Knepley ierr = PetscNewLog(prob, &b);CHKERRQ(ierr); 24712764a2aaSMatthew G. Knepley prob->data = b; 24722764a2aaSMatthew G. Knepley 24732764a2aaSMatthew G. Knepley ierr = PetscDSInitialize_Basic(prob);CHKERRQ(ierr); 24742764a2aaSMatthew G. Knepley PetscFunctionReturn(0); 24752764a2aaSMatthew G. Knepley } 2476