xref: /petsc/src/dm/dt/interface/dtds.c (revision 0c2f287639dd116cbd3e827a9c6bd5367ff51efa)
12764a2aaSMatthew G. Knepley #include <petsc-private/petscdsimpl.h> /*I "petscds.h" I*/
22764a2aaSMatthew G. Knepley 
32764a2aaSMatthew G. Knepley PetscClassId PETSCDS_CLASSID = 0;
42764a2aaSMatthew G. Knepley 
52764a2aaSMatthew G. Knepley PetscFunctionList PetscDSList              = NULL;
62764a2aaSMatthew G. Knepley PetscBool         PetscDSRegisterAllCalled = PETSC_FALSE;
72764a2aaSMatthew G. Knepley 
82764a2aaSMatthew G. Knepley #undef __FUNCT__
92764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSRegister"
102764a2aaSMatthew G. Knepley /*@C
112764a2aaSMatthew G. Knepley   PetscDSRegister - Adds a new PetscDS implementation
122764a2aaSMatthew G. Knepley 
132764a2aaSMatthew G. Knepley   Not Collective
142764a2aaSMatthew G. Knepley 
152764a2aaSMatthew G. Knepley   Input Parameters:
162764a2aaSMatthew G. Knepley + name        - The name of a new user-defined creation routine
172764a2aaSMatthew G. Knepley - create_func - The creation routine itself
182764a2aaSMatthew G. Knepley 
192764a2aaSMatthew G. Knepley   Notes:
202764a2aaSMatthew G. Knepley   PetscDSRegister() may be called multiple times to add several user-defined PetscDSs
212764a2aaSMatthew G. Knepley 
222764a2aaSMatthew G. Knepley   Sample usage:
232764a2aaSMatthew G. Knepley .vb
242764a2aaSMatthew G. Knepley     PetscDSRegister("my_ds", MyPetscDSCreate);
252764a2aaSMatthew G. Knepley .ve
262764a2aaSMatthew G. Knepley 
272764a2aaSMatthew G. Knepley   Then, your PetscDS type can be chosen with the procedural interface via
282764a2aaSMatthew G. Knepley .vb
292764a2aaSMatthew G. Knepley     PetscDSCreate(MPI_Comm, PetscDS *);
302764a2aaSMatthew G. Knepley     PetscDSSetType(PetscDS, "my_ds");
312764a2aaSMatthew G. Knepley .ve
322764a2aaSMatthew G. Knepley    or at runtime via the option
332764a2aaSMatthew G. Knepley .vb
342764a2aaSMatthew G. Knepley     -petscds_type my_ds
352764a2aaSMatthew G. Knepley .ve
362764a2aaSMatthew G. Knepley 
372764a2aaSMatthew G. Knepley   Level: advanced
382764a2aaSMatthew G. Knepley 
392764a2aaSMatthew G. Knepley .keywords: PetscDS, register
402764a2aaSMatthew G. Knepley .seealso: PetscDSRegisterAll(), PetscDSRegisterDestroy()
412764a2aaSMatthew G. Knepley 
422764a2aaSMatthew G. Knepley @*/
432764a2aaSMatthew G. Knepley PetscErrorCode PetscDSRegister(const char sname[], PetscErrorCode (*function)(PetscDS))
442764a2aaSMatthew G. Knepley {
452764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
462764a2aaSMatthew G. Knepley 
472764a2aaSMatthew G. Knepley   PetscFunctionBegin;
482764a2aaSMatthew G. Knepley   ierr = PetscFunctionListAdd(&PetscDSList, sname, function);CHKERRQ(ierr);
492764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
502764a2aaSMatthew G. Knepley }
512764a2aaSMatthew G. Knepley 
522764a2aaSMatthew G. Knepley #undef __FUNCT__
532764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetType"
542764a2aaSMatthew G. Knepley /*@C
552764a2aaSMatthew G. Knepley   PetscDSSetType - Builds a particular PetscDS
562764a2aaSMatthew G. Knepley 
572764a2aaSMatthew G. Knepley   Collective on PetscDS
582764a2aaSMatthew G. Knepley 
592764a2aaSMatthew G. Knepley   Input Parameters:
602764a2aaSMatthew G. Knepley + prob - The PetscDS object
612764a2aaSMatthew G. Knepley - name - The kind of system
622764a2aaSMatthew G. Knepley 
632764a2aaSMatthew G. Knepley   Options Database Key:
642764a2aaSMatthew G. Knepley . -petscds_type <type> - Sets the PetscDS type; use -help for a list of available types
652764a2aaSMatthew G. Knepley 
662764a2aaSMatthew G. Knepley   Level: intermediate
672764a2aaSMatthew G. Knepley 
682764a2aaSMatthew G. Knepley .keywords: PetscDS, set, type
692764a2aaSMatthew G. Knepley .seealso: PetscDSGetType(), PetscDSCreate()
702764a2aaSMatthew G. Knepley @*/
712764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetType(PetscDS prob, PetscDSType name)
722764a2aaSMatthew G. Knepley {
732764a2aaSMatthew G. Knepley   PetscErrorCode (*r)(PetscDS);
742764a2aaSMatthew G. Knepley   PetscBool      match;
752764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
762764a2aaSMatthew G. Knepley 
772764a2aaSMatthew G. Knepley   PetscFunctionBegin;
782764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
792764a2aaSMatthew G. Knepley   ierr = PetscObjectTypeCompare((PetscObject) prob, name, &match);CHKERRQ(ierr);
802764a2aaSMatthew G. Knepley   if (match) PetscFunctionReturn(0);
812764a2aaSMatthew G. Knepley 
822764a2aaSMatthew G. Knepley   if (!PetscDSRegisterAllCalled) {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);
1202764a2aaSMatthew G. Knepley   if (!PetscDSRegisterAllCalled) {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__
1262764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSView"
1272764a2aaSMatthew G. Knepley /*@C
1282764a2aaSMatthew G. Knepley   PetscDSView - Views a PetscDS
1292764a2aaSMatthew G. Knepley 
1302764a2aaSMatthew G. Knepley   Collective on PetscDS
1312764a2aaSMatthew G. Knepley 
1322764a2aaSMatthew G. Knepley   Input Parameter:
1332764a2aaSMatthew G. Knepley + prob - the PetscDS object to view
1342764a2aaSMatthew G. Knepley - v  - the viewer
1352764a2aaSMatthew G. Knepley 
1362764a2aaSMatthew G. Knepley   Level: developer
1372764a2aaSMatthew G. Knepley 
1382764a2aaSMatthew G. Knepley .seealso PetscDSDestroy()
1392764a2aaSMatthew G. Knepley @*/
1402764a2aaSMatthew G. Knepley PetscErrorCode PetscDSView(PetscDS prob, PetscViewer v)
1412764a2aaSMatthew G. Knepley {
1422764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
1432764a2aaSMatthew G. Knepley 
1442764a2aaSMatthew G. Knepley   PetscFunctionBegin;
1452764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
1462764a2aaSMatthew G. Knepley   if (!v) {ierr = PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject) prob), &v);CHKERRQ(ierr);}
1472764a2aaSMatthew G. Knepley   if (prob->ops->view) {ierr = (*prob->ops->view)(prob, v);CHKERRQ(ierr);}
1482764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
1492764a2aaSMatthew G. Knepley }
1502764a2aaSMatthew G. Knepley 
1512764a2aaSMatthew G. Knepley #undef __FUNCT__
1522764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSViewFromOptions"
1532764a2aaSMatthew G. Knepley /*
1542764a2aaSMatthew G. Knepley   PetscDSViewFromOptions - Processes command line options to determine if/how a PetscDS is to be viewed.
1552764a2aaSMatthew G. Knepley 
1562764a2aaSMatthew G. Knepley   Collective on PetscDS
1572764a2aaSMatthew G. Knepley 
1582764a2aaSMatthew G. Knepley   Input Parameters:
1592764a2aaSMatthew G. Knepley + prob   - the PetscDS
1602764a2aaSMatthew G. Knepley . prefix - prefix to use for viewing, or NULL to use prefix of 'rnd'
1612764a2aaSMatthew G. Knepley - optionname - option to activate viewing
1622764a2aaSMatthew G. Knepley 
1632764a2aaSMatthew G. Knepley   Level: intermediate
1642764a2aaSMatthew G. Knepley 
1652764a2aaSMatthew G. Knepley .keywords: PetscDS, view, options, database
1662764a2aaSMatthew G. Knepley .seealso: VecViewFromOptions(), MatViewFromOptions()
1672764a2aaSMatthew G. Knepley */
1682764a2aaSMatthew G. Knepley PetscErrorCode PetscDSViewFromOptions(PetscDS prob, const char prefix[], const char optionname[])
1692764a2aaSMatthew G. Knepley {
1702764a2aaSMatthew G. Knepley   PetscViewer       viewer;
1712764a2aaSMatthew G. Knepley   PetscViewerFormat format;
1722764a2aaSMatthew G. Knepley   PetscBool         flg;
1732764a2aaSMatthew G. Knepley   PetscErrorCode    ierr;
1742764a2aaSMatthew G. Knepley 
1752764a2aaSMatthew G. Knepley   PetscFunctionBegin;
1762764a2aaSMatthew G. Knepley   if (prefix) {ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject) prob), prefix, optionname, &viewer, &format, &flg);CHKERRQ(ierr);}
1772764a2aaSMatthew G. Knepley   else        {ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject) prob), ((PetscObject) prob)->prefix, optionname, &viewer, &format, &flg);CHKERRQ(ierr);}
1782764a2aaSMatthew G. Knepley   if (flg) {
1792764a2aaSMatthew G. Knepley     ierr = PetscViewerPushFormat(viewer, format);CHKERRQ(ierr);
1802764a2aaSMatthew G. Knepley     ierr = PetscDSView(prob, viewer);CHKERRQ(ierr);
1812764a2aaSMatthew G. Knepley     ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr);
1822764a2aaSMatthew G. Knepley     ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr);
1832764a2aaSMatthew G. Knepley   }
1842764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
1852764a2aaSMatthew G. Knepley }
1862764a2aaSMatthew G. Knepley 
1872764a2aaSMatthew G. Knepley #undef __FUNCT__
1882764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetFromOptions"
1892764a2aaSMatthew G. Knepley /*@
1902764a2aaSMatthew G. Knepley   PetscDSSetFromOptions - sets parameters in a PetscDS from the options database
1912764a2aaSMatthew G. Knepley 
1922764a2aaSMatthew G. Knepley   Collective on PetscDS
1932764a2aaSMatthew G. Knepley 
1942764a2aaSMatthew G. Knepley   Input Parameter:
1952764a2aaSMatthew G. Knepley . prob - the PetscDS object to set options for
1962764a2aaSMatthew G. Knepley 
1972764a2aaSMatthew G. Knepley   Options Database:
1982764a2aaSMatthew G. Knepley 
1992764a2aaSMatthew G. Knepley   Level: developer
2002764a2aaSMatthew G. Knepley 
2012764a2aaSMatthew G. Knepley .seealso PetscDSView()
2022764a2aaSMatthew G. Knepley @*/
2032764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetFromOptions(PetscDS prob)
2042764a2aaSMatthew G. Knepley {
2052764a2aaSMatthew G. Knepley   const char    *defaultType;
2062764a2aaSMatthew G. Knepley   char           name[256];
2072764a2aaSMatthew G. Knepley   PetscBool      flg;
2082764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
2092764a2aaSMatthew G. Knepley 
2102764a2aaSMatthew G. Knepley   PetscFunctionBegin;
2112764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
2122764a2aaSMatthew G. Knepley   if (!((PetscObject) prob)->type_name) {
2132764a2aaSMatthew G. Knepley     defaultType = PETSCDSBASIC;
2142764a2aaSMatthew G. Knepley   } else {
2152764a2aaSMatthew G. Knepley     defaultType = ((PetscObject) prob)->type_name;
2162764a2aaSMatthew G. Knepley   }
2172764a2aaSMatthew G. Knepley   if (!PetscDSRegisterAllCalled) {ierr = PetscDSRegisterAll();CHKERRQ(ierr);}
2182764a2aaSMatthew G. Knepley 
2192764a2aaSMatthew G. Knepley   ierr = PetscObjectOptionsBegin((PetscObject) prob);CHKERRQ(ierr);
2202764a2aaSMatthew G. Knepley   ierr = PetscOptionsFList("-petscds_type", "Discrete System", "PetscDSSetType", PetscDSList, defaultType, name, 256, &flg);CHKERRQ(ierr);
2212764a2aaSMatthew G. Knepley   if (flg) {
2222764a2aaSMatthew G. Knepley     ierr = PetscDSSetType(prob, name);CHKERRQ(ierr);
2232764a2aaSMatthew G. Knepley   } else if (!((PetscObject) prob)->type_name) {
2242764a2aaSMatthew G. Knepley     ierr = PetscDSSetType(prob, defaultType);CHKERRQ(ierr);
2252764a2aaSMatthew G. Knepley   }
2262764a2aaSMatthew G. Knepley   if (prob->ops->setfromoptions) {ierr = (*prob->ops->setfromoptions)(prob);CHKERRQ(ierr);}
2272764a2aaSMatthew G. Knepley   /* process any options handlers added with PetscObjectAddOptionsHandler() */
2282764a2aaSMatthew G. Knepley   ierr = PetscObjectProcessOptionsHandlers((PetscObject) prob);CHKERRQ(ierr);
2292764a2aaSMatthew G. Knepley   ierr = PetscOptionsEnd();CHKERRQ(ierr);
2302764a2aaSMatthew G. Knepley   ierr = PetscDSViewFromOptions(prob, NULL, "-petscds_view");CHKERRQ(ierr);
2312764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
2322764a2aaSMatthew G. Knepley }
2332764a2aaSMatthew G. Knepley 
2342764a2aaSMatthew G. Knepley #undef __FUNCT__
2352764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetUp"
2362764a2aaSMatthew G. Knepley /*@C
2372764a2aaSMatthew G. Knepley   PetscDSSetUp - Construct data structures for the PetscDS
2382764a2aaSMatthew G. Knepley 
2392764a2aaSMatthew G. Knepley   Collective on PetscDS
2402764a2aaSMatthew G. Knepley 
2412764a2aaSMatthew G. Knepley   Input Parameter:
2422764a2aaSMatthew G. Knepley . prob - the PetscDS object to setup
2432764a2aaSMatthew G. Knepley 
2442764a2aaSMatthew G. Knepley   Level: developer
2452764a2aaSMatthew G. Knepley 
2462764a2aaSMatthew G. Knepley .seealso PetscDSView(), PetscDSDestroy()
2472764a2aaSMatthew G. Knepley @*/
2482764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetUp(PetscDS prob)
2492764a2aaSMatthew G. Knepley {
2502764a2aaSMatthew G. Knepley   const PetscInt Nf = prob->Nf;
2512764a2aaSMatthew G. Knepley   PetscInt       dim, work, NcMax = 0, NqMax = 0, f;
2522764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
2532764a2aaSMatthew G. Knepley 
2542764a2aaSMatthew G. Knepley   PetscFunctionBegin;
2552764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
2562764a2aaSMatthew G. Knepley   if (prob->setup) PetscFunctionReturn(0);
2572764a2aaSMatthew G. Knepley   /* Calculate sizes */
2582764a2aaSMatthew G. Knepley   ierr = PetscDSGetSpatialDimension(prob, &dim);CHKERRQ(ierr);
2592764a2aaSMatthew G. Knepley   prob->totDim = prob->totDimBd = prob->totComp = 0;
2602764a2aaSMatthew G. Knepley   ierr = PetscMalloc4(Nf,&prob->basis,Nf,&prob->basisDer,Nf,&prob->basisBd,Nf,&prob->basisDerBd);CHKERRQ(ierr);
2612764a2aaSMatthew G. Knepley   for (f = 0; f < Nf; ++f) {
2622764a2aaSMatthew G. Knepley     PetscFE         fe   = (PetscFE) prob->disc[f];
2632764a2aaSMatthew G. Knepley     PetscFE         feBd = (PetscFE) prob->discBd[f];
2642764a2aaSMatthew G. Knepley     PetscQuadrature q;
2652764a2aaSMatthew G. Knepley     PetscInt        Nq, Nb, Nc;
2662764a2aaSMatthew G. Knepley 
2672764a2aaSMatthew G. Knepley     /* TODO Dispatch on discretization type*/
2682764a2aaSMatthew G. Knepley     ierr = PetscFEGetQuadrature(fe, &q);CHKERRQ(ierr);
2692764a2aaSMatthew G. Knepley     ierr = PetscQuadratureGetData(q, NULL, &Nq, NULL, NULL);CHKERRQ(ierr);
2702764a2aaSMatthew G. Knepley     ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr);
2712764a2aaSMatthew G. Knepley     ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr);
2722764a2aaSMatthew G. Knepley     ierr = PetscFEGetDefaultTabulation(fe, &prob->basis[f], &prob->basisDer[f], NULL);CHKERRQ(ierr);
2732764a2aaSMatthew G. Knepley     NqMax          = PetscMax(NqMax, Nq);
2742764a2aaSMatthew G. Knepley     NcMax          = PetscMax(NcMax, Nc);
2752764a2aaSMatthew G. Knepley     prob->totDim  += Nb*Nc;
2762764a2aaSMatthew G. Knepley     prob->totComp += Nc;
2772764a2aaSMatthew G. Knepley     if (feBd) {
2782764a2aaSMatthew G. Knepley       ierr = PetscFEGetDimension(feBd, &Nb);CHKERRQ(ierr);
2792764a2aaSMatthew G. Knepley       ierr = PetscFEGetNumComponents(feBd, &Nc);CHKERRQ(ierr);
2802764a2aaSMatthew G. Knepley       ierr = PetscFEGetDefaultTabulation(feBd, &prob->basisBd[f], &prob->basisDerBd[f], NULL);CHKERRQ(ierr);
2812764a2aaSMatthew G. Knepley       prob->totDimBd += Nb*Nc;
2822764a2aaSMatthew G. Knepley     }
2832764a2aaSMatthew G. Knepley   }
2842764a2aaSMatthew G. Knepley   work = PetscMax(prob->totComp*dim, PetscSqr(NcMax*dim));
2852764a2aaSMatthew G. Knepley   /* Allocate works space */
2862764a2aaSMatthew 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);
2872764a2aaSMatthew 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);
2882764a2aaSMatthew G. Knepley   if (prob->ops->setup) {ierr = (*prob->ops->setup)(prob);CHKERRQ(ierr);}
2892764a2aaSMatthew G. Knepley   prob->setup = PETSC_TRUE;
2902764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
2912764a2aaSMatthew G. Knepley }
2922764a2aaSMatthew G. Knepley 
2932764a2aaSMatthew G. Knepley #undef __FUNCT__
2942764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroyStructs_Static"
2952764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSDestroyStructs_Static(PetscDS prob)
2962764a2aaSMatthew G. Knepley {
2972764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
2982764a2aaSMatthew G. Knepley 
2992764a2aaSMatthew G. Knepley   PetscFunctionBegin;
3002764a2aaSMatthew G. Knepley   ierr = PetscFree4(prob->basis,prob->basisDer,prob->basisBd,prob->basisDerBd);CHKERRQ(ierr);
3012764a2aaSMatthew G. Knepley   ierr = PetscFree5(prob->u,prob->u_t,prob->u_x,prob->x,prob->refSpaceDer);CHKERRQ(ierr);
3022764a2aaSMatthew G. Knepley   ierr = PetscFree6(prob->f0,prob->f1,prob->g0,prob->g1,prob->g2,prob->g3);CHKERRQ(ierr);
3032764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
3042764a2aaSMatthew G. Knepley }
3052764a2aaSMatthew G. Knepley 
3062764a2aaSMatthew G. Knepley #undef __FUNCT__
3072764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSEnlarge_Static"
3082764a2aaSMatthew G. Knepley static PetscErrorCode PetscDSEnlarge_Static(PetscDS prob, PetscInt NfNew)
3092764a2aaSMatthew G. Knepley {
3102764a2aaSMatthew G. Knepley   PetscObject   *tmpd, *tmpdbd;
3112764a2aaSMatthew G. Knepley   PointFunc     *tmpobj, *tmpf, *tmpg;
3122764a2aaSMatthew G. Knepley   BdPointFunc   *tmpfbd, *tmpgbd;
313*0c2f2876SMatthew G. Knepley   RiemannFunc   *tmpr;
314*0c2f2876SMatthew G. Knepley   void         **tmpctx;
3152764a2aaSMatthew G. Knepley   PetscInt       Nf = prob->Nf, f;
3162764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
3172764a2aaSMatthew G. Knepley 
3182764a2aaSMatthew G. Knepley   PetscFunctionBegin;
3192764a2aaSMatthew G. Knepley   if (Nf >= NfNew) PetscFunctionReturn(0);
3202764a2aaSMatthew G. Knepley   prob->setup = PETSC_FALSE;
3212764a2aaSMatthew G. Knepley   ierr = PetscDSDestroyStructs_Static(prob);CHKERRQ(ierr);
3222764a2aaSMatthew G. Knepley   ierr = PetscMalloc1(NfNew, &tmpd);CHKERRQ(ierr);
3232764a2aaSMatthew G. Knepley   for (f = 0; f < Nf; ++f) tmpd[f] = prob->disc[f];
3242764a2aaSMatthew G. Knepley   for (f = Nf; f < NfNew; ++f) {ierr = PetscContainerCreate(PetscObjectComm((PetscObject) prob), (PetscContainer *) &tmpd[f]);CHKERRQ(ierr);}
3252764a2aaSMatthew G. Knepley   ierr = PetscFree(prob->disc);CHKERRQ(ierr);
3262764a2aaSMatthew G. Knepley   prob->Nf   = NfNew;
3272764a2aaSMatthew G. Knepley   prob->disc = tmpd;
328*0c2f2876SMatthew G. Knepley   ierr = PetscCalloc5(NfNew, &tmpobj, NfNew*2, &tmpf, NfNew*NfNew*4, &tmpg, NfNew, &tmpr, NfNew, &tmpctx);CHKERRQ(ierr);
3292764a2aaSMatthew G. Knepley   for (f = 0; f < Nf; ++f) tmpobj[f] = prob->obj[f];
3302764a2aaSMatthew G. Knepley   for (f = 0; f < Nf*2; ++f) tmpf[f] = prob->f[f];
3312764a2aaSMatthew G. Knepley   for (f = 0; f < Nf*Nf*4; ++f) tmpg[f] = prob->g[f];
332*0c2f2876SMatthew G. Knepley   for (f = 0; f < Nf; ++f) tmpr[f] = prob->r[f];
333*0c2f2876SMatthew G. Knepley   for (f = 0; f < Nf; ++f) tmpctx[f] = prob->ctx[f];
3342764a2aaSMatthew G. Knepley   for (f = Nf; f < NfNew; ++f) tmpobj[f] = NULL;
3352764a2aaSMatthew G. Knepley   for (f = Nf*2; f < NfNew*2; ++f) tmpf[f] = NULL;
3362764a2aaSMatthew G. Knepley   for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpg[f] = NULL;
337*0c2f2876SMatthew G. Knepley   for (f = Nf; f < NfNew; ++f) tmpr[f] = NULL;
338*0c2f2876SMatthew G. Knepley   for (f = Nf; f < NfNew; ++f) tmpctx[f] = NULL;
339*0c2f2876SMatthew G. Knepley   ierr = PetscFree5(prob->obj, prob->f, prob->g, prob->r, prob->ctx);CHKERRQ(ierr);
3402764a2aaSMatthew G. Knepley   prob->obj = tmpobj;
3412764a2aaSMatthew G. Knepley   prob->f   = tmpf;
3422764a2aaSMatthew G. Knepley   prob->g   = tmpg;
343*0c2f2876SMatthew G. Knepley   prob->r   = tmpr;
344*0c2f2876SMatthew G. Knepley   prob->ctx = tmpctx;
3452764a2aaSMatthew G. Knepley   ierr = PetscMalloc1(NfNew, &tmpdbd);CHKERRQ(ierr);
3462764a2aaSMatthew G. Knepley   for (f = 0; f < Nf; ++f) tmpdbd[f] = prob->discBd[f];
3472764a2aaSMatthew G. Knepley   for (f = Nf; f < NfNew; ++f) tmpdbd[f] = NULL;
3482764a2aaSMatthew G. Knepley   ierr = PetscFree(prob->discBd);CHKERRQ(ierr);
3492764a2aaSMatthew G. Knepley   prob->discBd = tmpdbd;
3502764a2aaSMatthew G. Knepley   ierr = PetscCalloc2(NfNew*2, &tmpfbd, NfNew*NfNew*4, &tmpgbd);CHKERRQ(ierr);
3512764a2aaSMatthew G. Knepley   for (f = 0; f < Nf*2; ++f) tmpfbd[f] = prob->fBd[f];
3522764a2aaSMatthew G. Knepley   for (f = 0; f < Nf*Nf*4; ++f) tmpgbd[f] = prob->gBd[f];
3532764a2aaSMatthew G. Knepley   for (f = Nf*2; f < NfNew*2; ++f) tmpfbd[f] = NULL;
3542764a2aaSMatthew G. Knepley   for (f = Nf*Nf*4; f < NfNew*NfNew*4; ++f) tmpgbd[f] = NULL;
3552764a2aaSMatthew G. Knepley   ierr = PetscFree2(prob->fBd, prob->gBd);CHKERRQ(ierr);
3562764a2aaSMatthew G. Knepley   prob->fBd = tmpfbd;
3572764a2aaSMatthew G. Knepley   prob->gBd = tmpgbd;
3582764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
3592764a2aaSMatthew G. Knepley }
3602764a2aaSMatthew G. Knepley 
3612764a2aaSMatthew G. Knepley #undef __FUNCT__
3622764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroy"
3632764a2aaSMatthew G. Knepley /*@
3642764a2aaSMatthew G. Knepley   PetscDSDestroy - Destroys a PetscDS object
3652764a2aaSMatthew G. Knepley 
3662764a2aaSMatthew G. Knepley   Collective on PetscDS
3672764a2aaSMatthew G. Knepley 
3682764a2aaSMatthew G. Knepley   Input Parameter:
3692764a2aaSMatthew G. Knepley . prob - the PetscDS object to destroy
3702764a2aaSMatthew G. Knepley 
3712764a2aaSMatthew G. Knepley   Level: developer
3722764a2aaSMatthew G. Knepley 
3732764a2aaSMatthew G. Knepley .seealso PetscDSView()
3742764a2aaSMatthew G. Knepley @*/
3752764a2aaSMatthew G. Knepley PetscErrorCode PetscDSDestroy(PetscDS *prob)
3762764a2aaSMatthew G. Knepley {
3772764a2aaSMatthew G. Knepley   PetscInt       f;
3782764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
3792764a2aaSMatthew G. Knepley 
3802764a2aaSMatthew G. Knepley   PetscFunctionBegin;
3812764a2aaSMatthew G. Knepley   if (!*prob) PetscFunctionReturn(0);
3822764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific((*prob), PETSCDS_CLASSID, 1);
3832764a2aaSMatthew G. Knepley 
3842764a2aaSMatthew G. Knepley   if (--((PetscObject)(*prob))->refct > 0) {*prob = 0; PetscFunctionReturn(0);}
3852764a2aaSMatthew G. Knepley   ((PetscObject) (*prob))->refct = 0;
3862764a2aaSMatthew G. Knepley   ierr = PetscDSDestroyStructs_Static(*prob);CHKERRQ(ierr);
3872764a2aaSMatthew G. Knepley   for (f = 0; f < (*prob)->Nf; ++f) {
3882764a2aaSMatthew G. Knepley     ierr = PetscObjectDereference((*prob)->disc[f]);CHKERRQ(ierr);
3892764a2aaSMatthew G. Knepley     ierr = PetscObjectDereference((*prob)->discBd[f]);CHKERRQ(ierr);
3902764a2aaSMatthew G. Knepley   }
3912764a2aaSMatthew G. Knepley   ierr = PetscFree((*prob)->disc);CHKERRQ(ierr);
3922764a2aaSMatthew G. Knepley   ierr = PetscFree((*prob)->discBd);CHKERRQ(ierr);
393*0c2f2876SMatthew G. Knepley   ierr = PetscFree5((*prob)->obj,(*prob)->f,(*prob)->g,(*prob)->r,(*prob)->ctx);CHKERRQ(ierr);
3942764a2aaSMatthew G. Knepley   ierr = PetscFree2((*prob)->fBd,(*prob)->gBd);CHKERRQ(ierr);
3952764a2aaSMatthew G. Knepley   if ((*prob)->ops->destroy) {ierr = (*(*prob)->ops->destroy)(*prob);CHKERRQ(ierr);}
3962764a2aaSMatthew G. Knepley   ierr = PetscHeaderDestroy(prob);CHKERRQ(ierr);
3972764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
3982764a2aaSMatthew G. Knepley }
3992764a2aaSMatthew G. Knepley 
4002764a2aaSMatthew G. Knepley #undef __FUNCT__
4012764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSCreate"
4022764a2aaSMatthew G. Knepley /*@
4032764a2aaSMatthew G. Knepley   PetscDSCreate - Creates an empty PetscDS object. The type can then be set with PetscDSSetType().
4042764a2aaSMatthew G. Knepley 
4052764a2aaSMatthew G. Knepley   Collective on MPI_Comm
4062764a2aaSMatthew G. Knepley 
4072764a2aaSMatthew G. Knepley   Input Parameter:
4082764a2aaSMatthew G. Knepley . comm - The communicator for the PetscDS object
4092764a2aaSMatthew G. Knepley 
4102764a2aaSMatthew G. Knepley   Output Parameter:
4112764a2aaSMatthew G. Knepley . prob - The PetscDS object
4122764a2aaSMatthew G. Knepley 
4132764a2aaSMatthew G. Knepley   Level: beginner
4142764a2aaSMatthew G. Knepley 
4152764a2aaSMatthew G. Knepley .seealso: PetscDSSetType(), PETSCDSBASIC
4162764a2aaSMatthew G. Knepley @*/
4172764a2aaSMatthew G. Knepley PetscErrorCode PetscDSCreate(MPI_Comm comm, PetscDS *prob)
4182764a2aaSMatthew G. Knepley {
4192764a2aaSMatthew G. Knepley   PetscDS   p;
4202764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
4212764a2aaSMatthew G. Knepley 
4222764a2aaSMatthew G. Knepley   PetscFunctionBegin;
4232764a2aaSMatthew G. Knepley   PetscValidPointer(prob, 2);
4242764a2aaSMatthew G. Knepley   *prob  = NULL;
4252764a2aaSMatthew G. Knepley   ierr = PetscDSInitializePackage();CHKERRQ(ierr);
4262764a2aaSMatthew G. Knepley 
4272764a2aaSMatthew G. Knepley   ierr = PetscHeaderCreate(p, _p_PetscDS, struct _PetscDSOps, PETSCDS_CLASSID, "PetscDS", "Discrete System", "PetscDS", comm, PetscDSDestroy, PetscDSView);CHKERRQ(ierr);
4282764a2aaSMatthew G. Knepley   ierr = PetscMemzero(p->ops, sizeof(struct _PetscDSOps));CHKERRQ(ierr);
4292764a2aaSMatthew G. Knepley 
4302764a2aaSMatthew G. Knepley   p->Nf    = 0;
4312764a2aaSMatthew G. Knepley   p->setup = PETSC_FALSE;
4322764a2aaSMatthew G. Knepley 
4332764a2aaSMatthew G. Knepley   *prob = p;
4342764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
4352764a2aaSMatthew G. Knepley }
4362764a2aaSMatthew G. Knepley 
4372764a2aaSMatthew G. Knepley #undef __FUNCT__
4382764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetNumFields"
4392764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetNumFields(PetscDS prob, PetscInt *Nf)
4402764a2aaSMatthew G. Knepley {
4412764a2aaSMatthew G. Knepley   PetscFunctionBegin;
4422764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
4432764a2aaSMatthew G. Knepley   PetscValidPointer(Nf, 2);
4442764a2aaSMatthew G. Knepley   *Nf = prob->Nf;
4452764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
4462764a2aaSMatthew G. Knepley }
4472764a2aaSMatthew G. Knepley 
4482764a2aaSMatthew G. Knepley #undef __FUNCT__
4492764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetSpatialDimension"
4502764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetSpatialDimension(PetscDS prob, PetscInt *dim)
4512764a2aaSMatthew G. Knepley {
4522764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
4532764a2aaSMatthew G. Knepley 
4542764a2aaSMatthew G. Knepley   PetscFunctionBegin;
4552764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
4562764a2aaSMatthew G. Knepley   PetscValidPointer(dim, 2);
4572764a2aaSMatthew G. Knepley   *dim = 0;
4582764a2aaSMatthew G. Knepley   if (prob->Nf) {ierr = PetscFEGetSpatialDimension((PetscFE) prob->disc[0], dim);CHKERRQ(ierr);}
4592764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
4602764a2aaSMatthew G. Knepley }
4612764a2aaSMatthew G. Knepley 
4622764a2aaSMatthew G. Knepley #undef __FUNCT__
4632764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalDimension"
4642764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalDimension(PetscDS prob, PetscInt *dim)
4652764a2aaSMatthew G. Knepley {
4662764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
4672764a2aaSMatthew G. Knepley 
4682764a2aaSMatthew G. Knepley   PetscFunctionBegin;
4692764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
4702764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
4712764a2aaSMatthew G. Knepley   PetscValidPointer(dim, 2);
4722764a2aaSMatthew G. Knepley   *dim = prob->totDim;
4732764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
4742764a2aaSMatthew G. Knepley }
4752764a2aaSMatthew G. Knepley 
4762764a2aaSMatthew G. Knepley #undef __FUNCT__
4772764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalBdDimension"
4782764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalBdDimension(PetscDS prob, PetscInt *dim)
4792764a2aaSMatthew G. Knepley {
4802764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
4812764a2aaSMatthew G. Knepley 
4822764a2aaSMatthew G. Knepley   PetscFunctionBegin;
4832764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
4842764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
4852764a2aaSMatthew G. Knepley   PetscValidPointer(dim, 2);
4862764a2aaSMatthew G. Knepley   *dim = prob->totDimBd;
4872764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
4882764a2aaSMatthew G. Knepley }
4892764a2aaSMatthew G. Knepley 
4902764a2aaSMatthew G. Knepley #undef __FUNCT__
4912764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTotalComponents"
4922764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTotalComponents(PetscDS prob, PetscInt *Nc)
4932764a2aaSMatthew G. Knepley {
4942764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
4952764a2aaSMatthew G. Knepley 
4962764a2aaSMatthew G. Knepley   PetscFunctionBegin;
4972764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
4982764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
4992764a2aaSMatthew G. Knepley   PetscValidPointer(Nc, 2);
5002764a2aaSMatthew G. Knepley   *Nc = prob->totComp;
5012764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
5022764a2aaSMatthew G. Knepley }
5032764a2aaSMatthew G. Knepley 
5042764a2aaSMatthew G. Knepley #undef __FUNCT__
5052764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetDiscretization"
5062764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetDiscretization(PetscDS prob, PetscInt f, PetscObject *disc)
5072764a2aaSMatthew G. Knepley {
5082764a2aaSMatthew G. Knepley   PetscFunctionBegin;
5092764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
5102764a2aaSMatthew G. Knepley   PetscValidPointer(disc, 3);
5112764a2aaSMatthew 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);
5122764a2aaSMatthew G. Knepley   *disc = prob->disc[f];
5132764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
5142764a2aaSMatthew G. Knepley }
5152764a2aaSMatthew G. Knepley 
5162764a2aaSMatthew G. Knepley #undef __FUNCT__
5172764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdDiscretization"
5182764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdDiscretization(PetscDS prob, PetscInt f, PetscObject *disc)
5192764a2aaSMatthew G. Knepley {
5202764a2aaSMatthew G. Knepley   PetscFunctionBegin;
5212764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
5222764a2aaSMatthew G. Knepley   PetscValidPointer(disc, 3);
5232764a2aaSMatthew 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);
5242764a2aaSMatthew G. Knepley   *disc = prob->discBd[f];
5252764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
5262764a2aaSMatthew G. Knepley }
5272764a2aaSMatthew G. Knepley 
5282764a2aaSMatthew G. Knepley #undef __FUNCT__
5292764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetDiscretization"
5302764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetDiscretization(PetscDS prob, PetscInt f, PetscObject disc)
5312764a2aaSMatthew G. Knepley {
5322764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
5332764a2aaSMatthew G. Knepley 
5342764a2aaSMatthew G. Knepley   PetscFunctionBegin;
5352764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
5362764a2aaSMatthew G. Knepley   PetscValidPointer(disc, 3);
5372764a2aaSMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
5382764a2aaSMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr);
5392764a2aaSMatthew G. Knepley   if (prob->disc[f]) {ierr = PetscObjectDereference(prob->disc[f]);CHKERRQ(ierr);}
5402764a2aaSMatthew G. Knepley   prob->disc[f] = disc;
5412764a2aaSMatthew G. Knepley   ierr = PetscObjectReference(disc);CHKERRQ(ierr);
5422764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
5432764a2aaSMatthew G. Knepley }
5442764a2aaSMatthew G. Knepley 
5452764a2aaSMatthew G. Knepley #undef __FUNCT__
5462764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdDiscretization"
5472764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdDiscretization(PetscDS prob, PetscInt f, PetscObject disc)
5482764a2aaSMatthew G. Knepley {
5492764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
5502764a2aaSMatthew G. Knepley 
5512764a2aaSMatthew G. Knepley   PetscFunctionBegin;
5522764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
5532764a2aaSMatthew G. Knepley   if (disc) PetscValidPointer(disc, 3);
5542764a2aaSMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
5552764a2aaSMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr);
5562764a2aaSMatthew G. Knepley   if (prob->discBd[f]) {ierr = PetscObjectDereference(prob->discBd[f]);CHKERRQ(ierr);}
5572764a2aaSMatthew G. Knepley   prob->discBd[f] = disc;
5582764a2aaSMatthew G. Knepley   ierr = PetscObjectReference(disc);CHKERRQ(ierr);
5592764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
5602764a2aaSMatthew G. Knepley }
5612764a2aaSMatthew G. Knepley 
5622764a2aaSMatthew G. Knepley #undef __FUNCT__
5632764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSAddDiscretization"
5642764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddDiscretization(PetscDS prob, PetscObject disc)
5652764a2aaSMatthew G. Knepley {
5662764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
5672764a2aaSMatthew G. Knepley 
5682764a2aaSMatthew G. Knepley   PetscFunctionBegin;
5692764a2aaSMatthew G. Knepley   ierr = PetscDSSetDiscretization(prob, prob->Nf, disc);CHKERRQ(ierr);
5702764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
5712764a2aaSMatthew G. Knepley }
5722764a2aaSMatthew G. Knepley 
5732764a2aaSMatthew G. Knepley #undef __FUNCT__
5742764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSAddBdDiscretization"
5752764a2aaSMatthew G. Knepley PetscErrorCode PetscDSAddBdDiscretization(PetscDS prob, PetscObject disc)
5762764a2aaSMatthew G. Knepley {
5772764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
5782764a2aaSMatthew G. Knepley 
5792764a2aaSMatthew G. Knepley   PetscFunctionBegin;
5802764a2aaSMatthew G. Knepley   ierr = PetscDSSetBdDiscretization(prob, prob->Nf, disc);CHKERRQ(ierr);
5812764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
5822764a2aaSMatthew G. Knepley }
5832764a2aaSMatthew G. Knepley 
5842764a2aaSMatthew G. Knepley #undef __FUNCT__
5852764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetObjective"
5862764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetObjective(PetscDS prob, PetscInt f,
5872764a2aaSMatthew G. Knepley                                         void (**obj)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], PetscScalar obj[]))
5882764a2aaSMatthew G. Knepley {
5892764a2aaSMatthew G. Knepley   PetscFunctionBegin;
5902764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
5912764a2aaSMatthew G. Knepley   PetscValidPointer(obj, 2);
5922764a2aaSMatthew 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);
5932764a2aaSMatthew G. Knepley   *obj = prob->obj[f];
5942764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
5952764a2aaSMatthew G. Knepley }
5962764a2aaSMatthew G. Knepley 
5972764a2aaSMatthew G. Knepley #undef __FUNCT__
5982764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetObjective"
5992764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetObjective(PetscDS prob, PetscInt f,
6002764a2aaSMatthew G. Knepley                                         void (*obj)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], PetscScalar obj[]))
6012764a2aaSMatthew G. Knepley {
6022764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
6032764a2aaSMatthew G. Knepley 
6042764a2aaSMatthew G. Knepley   PetscFunctionBegin;
6052764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
6062764a2aaSMatthew G. Knepley   PetscValidFunction(obj, 2);
6072764a2aaSMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
6082764a2aaSMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr);
6092764a2aaSMatthew G. Knepley   prob->obj[f] = obj;
6102764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
6112764a2aaSMatthew G. Knepley }
6122764a2aaSMatthew G. Knepley 
6132764a2aaSMatthew G. Knepley #undef __FUNCT__
6142764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetResidual"
6152764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetResidual(PetscDS prob, PetscInt f,
6162764a2aaSMatthew G. Knepley                                        void (**f0)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], PetscScalar f0[]),
6172764a2aaSMatthew G. Knepley                                        void (**f1)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], PetscScalar f1[]))
6182764a2aaSMatthew G. Knepley {
6192764a2aaSMatthew G. Knepley   PetscFunctionBegin;
6202764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
6212764a2aaSMatthew 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);
6222764a2aaSMatthew G. Knepley   if (f0) {PetscValidPointer(f0, 3); *f0 = prob->f[f*2+0];}
6232764a2aaSMatthew G. Knepley   if (f1) {PetscValidPointer(f1, 4); *f1 = prob->f[f*2+1];}
6242764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
6252764a2aaSMatthew G. Knepley }
6262764a2aaSMatthew G. Knepley 
6272764a2aaSMatthew G. Knepley #undef __FUNCT__
6282764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetResidual"
6292764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetResidual(PetscDS prob, PetscInt f,
6302764a2aaSMatthew G. Knepley                                        void (*f0)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], PetscScalar f0[]),
6312764a2aaSMatthew G. Knepley                                        void (*f1)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], PetscScalar f1[]))
6322764a2aaSMatthew G. Knepley {
6332764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
6342764a2aaSMatthew G. Knepley 
6352764a2aaSMatthew G. Knepley   PetscFunctionBegin;
6362764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
6372764a2aaSMatthew G. Knepley   PetscValidFunction(f0, 3);
6382764a2aaSMatthew G. Knepley   PetscValidFunction(f1, 4);
6392764a2aaSMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
6402764a2aaSMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr);
6412764a2aaSMatthew G. Knepley   prob->f[f*2+0] = f0;
6422764a2aaSMatthew G. Knepley   prob->f[f*2+1] = f1;
6432764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
6442764a2aaSMatthew G. Knepley }
6452764a2aaSMatthew G. Knepley 
6462764a2aaSMatthew G. Knepley #undef __FUNCT__
6472764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetJacobian"
6482764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetJacobian(PetscDS prob, PetscInt f, PetscInt g,
6492764a2aaSMatthew G. Knepley                                        void (**g0)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], PetscScalar g0[]),
6502764a2aaSMatthew G. Knepley                                        void (**g1)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], PetscScalar g1[]),
6512764a2aaSMatthew G. Knepley                                        void (**g2)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], PetscScalar g2[]),
6522764a2aaSMatthew G. Knepley                                        void (**g3)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], PetscScalar g3[]))
6532764a2aaSMatthew G. Knepley {
6542764a2aaSMatthew G. Knepley   PetscFunctionBegin;
6552764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
6562764a2aaSMatthew 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);
6572764a2aaSMatthew 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);
6582764a2aaSMatthew G. Knepley   if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g[(f*prob->Nf + g)*4+0];}
6592764a2aaSMatthew G. Knepley   if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g[(f*prob->Nf + g)*4+1];}
6602764a2aaSMatthew G. Knepley   if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g[(f*prob->Nf + g)*4+2];}
6612764a2aaSMatthew G. Knepley   if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g[(f*prob->Nf + g)*4+3];}
6622764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
6632764a2aaSMatthew G. Knepley }
6642764a2aaSMatthew G. Knepley 
6652764a2aaSMatthew G. Knepley #undef __FUNCT__
6662764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetJacobian"
6672764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetJacobian(PetscDS prob, PetscInt f, PetscInt g,
6682764a2aaSMatthew G. Knepley                                        void (*g0)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], PetscScalar g0[]),
6692764a2aaSMatthew G. Knepley                                        void (*g1)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], PetscScalar g1[]),
6702764a2aaSMatthew G. Knepley                                        void (*g2)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], PetscScalar g2[]),
6712764a2aaSMatthew G. Knepley                                        void (*g3)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], PetscScalar g3[]))
6722764a2aaSMatthew G. Knepley {
6732764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
6742764a2aaSMatthew G. Knepley 
6752764a2aaSMatthew G. Knepley   PetscFunctionBegin;
6762764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
6772764a2aaSMatthew G. Knepley   if (g0) PetscValidFunction(g0, 4);
6782764a2aaSMatthew G. Knepley   if (g1) PetscValidFunction(g1, 5);
6792764a2aaSMatthew G. Knepley   if (g2) PetscValidFunction(g2, 6);
6802764a2aaSMatthew G. Knepley   if (g3) PetscValidFunction(g3, 7);
6812764a2aaSMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
6822764a2aaSMatthew G. Knepley   if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g);
6832764a2aaSMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr);
6842764a2aaSMatthew G. Knepley   prob->g[(f*prob->Nf + g)*4+0] = g0;
6852764a2aaSMatthew G. Knepley   prob->g[(f*prob->Nf + g)*4+1] = g1;
6862764a2aaSMatthew G. Knepley   prob->g[(f*prob->Nf + g)*4+2] = g2;
6872764a2aaSMatthew G. Knepley   prob->g[(f*prob->Nf + g)*4+3] = g3;
6882764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
6892764a2aaSMatthew G. Knepley }
6902764a2aaSMatthew G. Knepley 
6912764a2aaSMatthew G. Knepley #undef __FUNCT__
692*0c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSGetRiemannSolver"
693*0c2f2876SMatthew G. Knepley /*@C
694*0c2f2876SMatthew G. Knepley   PetscDSGetRiemannSolver - Returns the Riemann solver for the given field
695*0c2f2876SMatthew G. Knepley 
696*0c2f2876SMatthew G. Knepley   Not collective
697*0c2f2876SMatthew G. Knepley 
698*0c2f2876SMatthew G. Knepley   Input Arguments:
699*0c2f2876SMatthew G. Knepley + prob - The PetscDS object
700*0c2f2876SMatthew G. Knepley - f    - The field number
701*0c2f2876SMatthew G. Knepley 
702*0c2f2876SMatthew G. Knepley   Output Argument:
703*0c2f2876SMatthew G. Knepley . r    - Riemann solver
704*0c2f2876SMatthew G. Knepley 
705*0c2f2876SMatthew G. Knepley   Calling sequence for r:
706*0c2f2876SMatthew G. Knepley 
707*0c2f2876SMatthew G. Knepley $ r(const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx)
708*0c2f2876SMatthew G. Knepley 
709*0c2f2876SMatthew G. Knepley + x    - The coordinates at a point on the interface
710*0c2f2876SMatthew G. Knepley . n    - The normal vector to the interface
711*0c2f2876SMatthew G. Knepley . uL   - The state vector to the left of the interface
712*0c2f2876SMatthew G. Knepley . uR   - The state vector to the right of the interface
713*0c2f2876SMatthew G. Knepley . flux - output array of flux through the interface
714*0c2f2876SMatthew G. Knepley - ctx  - optional user context
715*0c2f2876SMatthew G. Knepley 
716*0c2f2876SMatthew G. Knepley   Level: intermediate
717*0c2f2876SMatthew G. Knepley 
718*0c2f2876SMatthew G. Knepley .seealso: PetscDSSetRiemannSolver()
719*0c2f2876SMatthew G. Knepley @*/
720*0c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetRiemannSolver(PetscDS prob, PetscInt f,
721*0c2f2876SMatthew G. Knepley                                        void (**r)(const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx))
722*0c2f2876SMatthew G. Knepley {
723*0c2f2876SMatthew G. Knepley   PetscFunctionBegin;
724*0c2f2876SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
725*0c2f2876SMatthew 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);
726*0c2f2876SMatthew G. Knepley   PetscValidPointer(r, 3);
727*0c2f2876SMatthew G. Knepley   *r = prob->r[f];
728*0c2f2876SMatthew G. Knepley   PetscFunctionReturn(0);
729*0c2f2876SMatthew G. Knepley }
730*0c2f2876SMatthew G. Knepley 
731*0c2f2876SMatthew G. Knepley #undef __FUNCT__
732*0c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSSetRiemannSolver"
733*0c2f2876SMatthew G. Knepley /*@C
734*0c2f2876SMatthew G. Knepley   PetscDSSetRiemannSolver - Sets the Riemann solver for the given field
735*0c2f2876SMatthew G. Knepley 
736*0c2f2876SMatthew G. Knepley   Not collective
737*0c2f2876SMatthew G. Knepley 
738*0c2f2876SMatthew G. Knepley   Input Arguments:
739*0c2f2876SMatthew G. Knepley + prob - The PetscDS object
740*0c2f2876SMatthew G. Knepley . f    - The field number
741*0c2f2876SMatthew G. Knepley - r    - Riemann solver
742*0c2f2876SMatthew G. Knepley 
743*0c2f2876SMatthew G. Knepley   Calling sequence for r:
744*0c2f2876SMatthew G. Knepley 
745*0c2f2876SMatthew G. Knepley $ r(const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx)
746*0c2f2876SMatthew G. Knepley 
747*0c2f2876SMatthew G. Knepley + x    - The coordinates at a point on the interface
748*0c2f2876SMatthew G. Knepley . n    - The normal vector to the interface
749*0c2f2876SMatthew G. Knepley . uL   - The state vector to the left of the interface
750*0c2f2876SMatthew G. Knepley . uR   - The state vector to the right of the interface
751*0c2f2876SMatthew G. Knepley . flux - output array of flux through the interface
752*0c2f2876SMatthew G. Knepley - ctx  - optional user context
753*0c2f2876SMatthew G. Knepley 
754*0c2f2876SMatthew G. Knepley   Level: intermediate
755*0c2f2876SMatthew G. Knepley 
756*0c2f2876SMatthew G. Knepley .seealso: PetscDSGetRiemannSolver()
757*0c2f2876SMatthew G. Knepley @*/
758*0c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetRiemannSolver(PetscDS prob, PetscInt f,
759*0c2f2876SMatthew G. Knepley                                        void (*r)(const PetscReal x[], const PetscReal n[], const PetscScalar uL[], const PetscScalar uR[], PetscScalar flux[], void *ctx))
760*0c2f2876SMatthew G. Knepley {
761*0c2f2876SMatthew G. Knepley   PetscErrorCode ierr;
762*0c2f2876SMatthew G. Knepley 
763*0c2f2876SMatthew G. Knepley   PetscFunctionBegin;
764*0c2f2876SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
765*0c2f2876SMatthew G. Knepley   PetscValidFunction(r, 3);
766*0c2f2876SMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
767*0c2f2876SMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr);
768*0c2f2876SMatthew G. Knepley   prob->r[f] = r;
769*0c2f2876SMatthew G. Knepley   PetscFunctionReturn(0);
770*0c2f2876SMatthew G. Knepley }
771*0c2f2876SMatthew G. Knepley 
772*0c2f2876SMatthew G. Knepley #undef __FUNCT__
773*0c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSGetContext"
774*0c2f2876SMatthew G. Knepley PetscErrorCode PetscDSGetContext(PetscDS prob, PetscInt f, void **ctx)
775*0c2f2876SMatthew G. Knepley {
776*0c2f2876SMatthew G. Knepley   PetscFunctionBegin;
777*0c2f2876SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
778*0c2f2876SMatthew 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);
779*0c2f2876SMatthew G. Knepley   PetscValidPointer(ctx, 3);
780*0c2f2876SMatthew G. Knepley   *ctx = prob->ctx[f];
781*0c2f2876SMatthew G. Knepley   PetscFunctionReturn(0);
782*0c2f2876SMatthew G. Knepley }
783*0c2f2876SMatthew G. Knepley 
784*0c2f2876SMatthew G. Knepley #undef __FUNCT__
785*0c2f2876SMatthew G. Knepley #define __FUNCT__ "PetscDSSetContext"
786*0c2f2876SMatthew G. Knepley PetscErrorCode PetscDSSetContext(PetscDS prob, PetscInt f, void *ctx)
787*0c2f2876SMatthew G. Knepley {
788*0c2f2876SMatthew G. Knepley   PetscErrorCode ierr;
789*0c2f2876SMatthew G. Knepley 
790*0c2f2876SMatthew G. Knepley   PetscFunctionBegin;
791*0c2f2876SMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
792*0c2f2876SMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
793*0c2f2876SMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr);
794*0c2f2876SMatthew G. Knepley   prob->ctx[f] = ctx;
795*0c2f2876SMatthew G. Knepley   PetscFunctionReturn(0);
796*0c2f2876SMatthew G. Knepley }
797*0c2f2876SMatthew G. Knepley 
798*0c2f2876SMatthew G. Knepley #undef __FUNCT__
7992764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdResidual"
8002764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdResidual(PetscDS prob, PetscInt f,
8012764a2aaSMatthew G. Knepley                                          void (**f0)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], const PetscReal n[], PetscScalar f0[]),
8022764a2aaSMatthew G. Knepley                                          void (**f1)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], const PetscReal n[], PetscScalar f1[]))
8032764a2aaSMatthew G. Knepley {
8042764a2aaSMatthew G. Knepley   PetscFunctionBegin;
8052764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
8062764a2aaSMatthew 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);
8072764a2aaSMatthew G. Knepley   if (f0) {PetscValidPointer(f0, 3); *f0 = prob->fBd[f*2+0];}
8082764a2aaSMatthew G. Knepley   if (f1) {PetscValidPointer(f1, 4); *f1 = prob->fBd[f*2+1];}
8092764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
8102764a2aaSMatthew G. Knepley }
8112764a2aaSMatthew G. Knepley 
8122764a2aaSMatthew G. Knepley #undef __FUNCT__
8132764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdResidual"
8142764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdResidual(PetscDS prob, PetscInt f,
8152764a2aaSMatthew G. Knepley                                          void (*f0)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], const PetscReal n[], PetscScalar f0[]),
8162764a2aaSMatthew G. Knepley                                          void (*f1)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], const PetscReal n[], PetscScalar f1[]))
8172764a2aaSMatthew G. Knepley {
8182764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
8192764a2aaSMatthew G. Knepley 
8202764a2aaSMatthew G. Knepley   PetscFunctionBegin;
8212764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
8222764a2aaSMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
8232764a2aaSMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, f+1);CHKERRQ(ierr);
8242764a2aaSMatthew G. Knepley   if (f0) {PetscValidFunction(f0, 3); prob->fBd[f*2+0] = f0;}
8252764a2aaSMatthew G. Knepley   if (f1) {PetscValidFunction(f1, 4); prob->fBd[f*2+1] = f1;}
8262764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
8272764a2aaSMatthew G. Knepley }
8282764a2aaSMatthew G. Knepley 
8292764a2aaSMatthew G. Knepley #undef __FUNCT__
8302764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdJacobian"
8312764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdJacobian(PetscDS prob, PetscInt f, PetscInt g,
8322764a2aaSMatthew G. Knepley                                          void (**g0)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], const PetscReal n[], PetscScalar g0[]),
8332764a2aaSMatthew G. Knepley                                          void (**g1)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], const PetscReal n[], PetscScalar g1[]),
8342764a2aaSMatthew G. Knepley                                          void (**g2)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], const PetscReal n[], PetscScalar g2[]),
8352764a2aaSMatthew G. Knepley                                          void (**g3)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], const PetscReal n[], PetscScalar g3[]))
8362764a2aaSMatthew G. Knepley {
8372764a2aaSMatthew G. Knepley   PetscFunctionBegin;
8382764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
8392764a2aaSMatthew 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);
8402764a2aaSMatthew 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);
8412764a2aaSMatthew G. Knepley   if (g0) {PetscValidPointer(g0, 4); *g0 = prob->gBd[(f*prob->Nf + g)*4+0];}
8422764a2aaSMatthew G. Knepley   if (g1) {PetscValidPointer(g1, 5); *g1 = prob->gBd[(f*prob->Nf + g)*4+1];}
8432764a2aaSMatthew G. Knepley   if (g2) {PetscValidPointer(g2, 6); *g2 = prob->gBd[(f*prob->Nf + g)*4+2];}
8442764a2aaSMatthew G. Knepley   if (g3) {PetscValidPointer(g3, 7); *g3 = prob->gBd[(f*prob->Nf + g)*4+3];}
8452764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
8462764a2aaSMatthew G. Knepley }
8472764a2aaSMatthew G. Knepley 
8482764a2aaSMatthew G. Knepley #undef __FUNCT__
8492764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSSetBdJacobian"
8502764a2aaSMatthew G. Knepley PetscErrorCode PetscDSSetBdJacobian(PetscDS prob, PetscInt f, PetscInt g,
8512764a2aaSMatthew G. Knepley                                          void (*g0)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], const PetscReal n[], PetscScalar g0[]),
8522764a2aaSMatthew G. Knepley                                          void (*g1)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], const PetscReal n[], PetscScalar g1[]),
8532764a2aaSMatthew G. Knepley                                          void (*g2)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], const PetscReal n[], PetscScalar g2[]),
8542764a2aaSMatthew G. Knepley                                          void (*g3)(const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[], const PetscReal x[], const PetscReal n[], PetscScalar g3[]))
8552764a2aaSMatthew G. Knepley {
8562764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
8572764a2aaSMatthew G. Knepley 
8582764a2aaSMatthew G. Knepley   PetscFunctionBegin;
8592764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
8602764a2aaSMatthew G. Knepley   if (g0) PetscValidFunction(g0, 4);
8612764a2aaSMatthew G. Knepley   if (g1) PetscValidFunction(g1, 5);
8622764a2aaSMatthew G. Knepley   if (g2) PetscValidFunction(g2, 6);
8632764a2aaSMatthew G. Knepley   if (g3) PetscValidFunction(g3, 7);
8642764a2aaSMatthew G. Knepley   if (f < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", f);
8652764a2aaSMatthew G. Knepley   if (g < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Field number %d must be non-negative", g);
8662764a2aaSMatthew G. Knepley   ierr = PetscDSEnlarge_Static(prob, PetscMax(f, g)+1);CHKERRQ(ierr);
8672764a2aaSMatthew G. Knepley   prob->gBd[(f*prob->Nf + g)*4+0] = g0;
8682764a2aaSMatthew G. Knepley   prob->gBd[(f*prob->Nf + g)*4+1] = g1;
8692764a2aaSMatthew G. Knepley   prob->gBd[(f*prob->Nf + g)*4+2] = g2;
8702764a2aaSMatthew G. Knepley   prob->gBd[(f*prob->Nf + g)*4+3] = g3;
8712764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
8722764a2aaSMatthew G. Knepley }
8732764a2aaSMatthew G. Knepley 
8742764a2aaSMatthew G. Knepley #undef __FUNCT__
8752764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetFieldOffset"
8762764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetFieldOffset(PetscDS prob, PetscInt f, PetscInt *off)
8772764a2aaSMatthew G. Knepley {
8782764a2aaSMatthew G. Knepley   PetscInt       g;
8792764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
8802764a2aaSMatthew G. Knepley 
8812764a2aaSMatthew G. Knepley   PetscFunctionBegin;
8822764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
8832764a2aaSMatthew G. Knepley   PetscValidPointer(off, 3);
8842764a2aaSMatthew 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);
8852764a2aaSMatthew G. Knepley   *off = 0;
8862764a2aaSMatthew G. Knepley   for (g = 0; g < f; ++g) {
8872764a2aaSMatthew G. Knepley     PetscFE  fe = (PetscFE) prob->disc[g];
8882764a2aaSMatthew G. Knepley     PetscInt Nb, Nc;
8892764a2aaSMatthew G. Knepley 
8902764a2aaSMatthew G. Knepley     ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr);
8912764a2aaSMatthew G. Knepley     ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr);
8922764a2aaSMatthew G. Knepley     *off += Nb*Nc;
8932764a2aaSMatthew G. Knepley   }
8942764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
8952764a2aaSMatthew G. Knepley }
8962764a2aaSMatthew G. Knepley 
8972764a2aaSMatthew G. Knepley #undef __FUNCT__
8982764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdFieldOffset"
8992764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdFieldOffset(PetscDS prob, PetscInt f, PetscInt *off)
9002764a2aaSMatthew G. Knepley {
9012764a2aaSMatthew G. Knepley   PetscInt       g;
9022764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
9032764a2aaSMatthew G. Knepley 
9042764a2aaSMatthew G. Knepley   PetscFunctionBegin;
9052764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
9062764a2aaSMatthew G. Knepley   PetscValidPointer(off, 3);
9072764a2aaSMatthew 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);
9082764a2aaSMatthew G. Knepley   *off = 0;
9092764a2aaSMatthew G. Knepley   for (g = 0; g < f; ++g) {
9102764a2aaSMatthew G. Knepley     PetscFE  fe = (PetscFE) prob->discBd[g];
9112764a2aaSMatthew G. Knepley     PetscInt Nb, Nc;
9122764a2aaSMatthew G. Knepley 
9132764a2aaSMatthew G. Knepley     ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr);
9142764a2aaSMatthew G. Knepley     ierr = PetscFEGetNumComponents(fe, &Nc);CHKERRQ(ierr);
9152764a2aaSMatthew G. Knepley     *off += Nb*Nc;
9162764a2aaSMatthew G. Knepley   }
9172764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
9182764a2aaSMatthew G. Knepley }
9192764a2aaSMatthew G. Knepley 
9202764a2aaSMatthew G. Knepley #undef __FUNCT__
9212764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetTabulation"
9222764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetTabulation(PetscDS prob, PetscReal ***basis, PetscReal ***basisDer)
9232764a2aaSMatthew G. Knepley {
9242764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
9252764a2aaSMatthew G. Knepley 
9262764a2aaSMatthew G. Knepley   PetscFunctionBegin;
9272764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
9282764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
9292764a2aaSMatthew G. Knepley   if (basis)    {PetscValidPointer(basis, 2);    *basis    = prob->basis;}
9302764a2aaSMatthew G. Knepley   if (basisDer) {PetscValidPointer(basisDer, 3); *basisDer = prob->basisDer;}
9312764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
9322764a2aaSMatthew G. Knepley }
9332764a2aaSMatthew G. Knepley 
9342764a2aaSMatthew G. Knepley #undef __FUNCT__
9352764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetBdTabulation"
9362764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetBdTabulation(PetscDS prob, PetscReal ***basis, PetscReal ***basisDer)
9372764a2aaSMatthew G. Knepley {
9382764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
9392764a2aaSMatthew G. Knepley 
9402764a2aaSMatthew G. Knepley   PetscFunctionBegin;
9412764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
9422764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
9432764a2aaSMatthew G. Knepley   if (basis)    {PetscValidPointer(basis, 2);    *basis    = prob->basisBd;}
9442764a2aaSMatthew G. Knepley   if (basisDer) {PetscValidPointer(basisDer, 3); *basisDer = prob->basisDerBd;}
9452764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
9462764a2aaSMatthew G. Knepley }
9472764a2aaSMatthew G. Knepley 
9482764a2aaSMatthew G. Knepley #undef __FUNCT__
9492764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetEvaluationArrays"
9502764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetEvaluationArrays(PetscDS prob, PetscScalar **u, PetscScalar **u_t, PetscScalar **u_x)
9512764a2aaSMatthew G. Knepley {
9522764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
9532764a2aaSMatthew G. Knepley 
9542764a2aaSMatthew G. Knepley   PetscFunctionBegin;
9552764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
9562764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
9572764a2aaSMatthew G. Knepley   if (u)   {PetscValidPointer(u, 2);   *u   = prob->u;}
9582764a2aaSMatthew G. Knepley   if (u_t) {PetscValidPointer(u_t, 3); *u_t = prob->u_t;}
9592764a2aaSMatthew G. Knepley   if (u_x) {PetscValidPointer(u_x, 4); *u_x = prob->u_x;}
9602764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
9612764a2aaSMatthew G. Knepley }
9622764a2aaSMatthew G. Knepley 
9632764a2aaSMatthew G. Knepley #undef __FUNCT__
9642764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetWeakFormArrays"
9652764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetWeakFormArrays(PetscDS prob, PetscScalar **f0, PetscScalar **f1, PetscScalar **g0, PetscScalar **g1, PetscScalar **g2, PetscScalar **g3)
9662764a2aaSMatthew G. Knepley {
9672764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
9682764a2aaSMatthew G. Knepley 
9692764a2aaSMatthew G. Knepley   PetscFunctionBegin;
9702764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
9712764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
9722764a2aaSMatthew G. Knepley   if (f0) {PetscValidPointer(f0, 2); *f0 = prob->f0;}
9732764a2aaSMatthew G. Knepley   if (f1) {PetscValidPointer(f1, 3); *f1 = prob->f1;}
9742764a2aaSMatthew G. Knepley   if (g0) {PetscValidPointer(g0, 4); *g0 = prob->g0;}
9752764a2aaSMatthew G. Knepley   if (g1) {PetscValidPointer(g1, 5); *g1 = prob->g1;}
9762764a2aaSMatthew G. Knepley   if (g2) {PetscValidPointer(g2, 6); *g2 = prob->g2;}
9772764a2aaSMatthew G. Knepley   if (g3) {PetscValidPointer(g3, 7); *g3 = prob->g3;}
9782764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
9792764a2aaSMatthew G. Knepley }
9802764a2aaSMatthew G. Knepley 
9812764a2aaSMatthew G. Knepley #undef __FUNCT__
9822764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSGetRefCoordArrays"
9832764a2aaSMatthew G. Knepley PetscErrorCode PetscDSGetRefCoordArrays(PetscDS prob, PetscReal **x, PetscScalar **refSpaceDer)
9842764a2aaSMatthew G. Knepley {
9852764a2aaSMatthew G. Knepley   PetscErrorCode ierr;
9862764a2aaSMatthew G. Knepley 
9872764a2aaSMatthew G. Knepley   PetscFunctionBegin;
9882764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCDS_CLASSID, 1);
9892764a2aaSMatthew G. Knepley   ierr = PetscDSSetUp(prob);CHKERRQ(ierr);
9902764a2aaSMatthew G. Knepley   if (x)           {PetscValidPointer(x, 2);           *x           = prob->x;}
9912764a2aaSMatthew G. Knepley   if (refSpaceDer) {PetscValidPointer(refSpaceDer, 3); *refSpaceDer = prob->refSpaceDer;}
9922764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
9932764a2aaSMatthew G. Knepley }
9942764a2aaSMatthew G. Knepley 
9952764a2aaSMatthew G. Knepley #undef __FUNCT__
9962764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSDestroy_Basic"
9972764a2aaSMatthew G. Knepley PetscErrorCode PetscDSDestroy_Basic(PetscDS prob)
9982764a2aaSMatthew G. Knepley {
9992764a2aaSMatthew G. Knepley   PetscFunctionBegin;
10002764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
10012764a2aaSMatthew G. Knepley }
10022764a2aaSMatthew G. Knepley 
10032764a2aaSMatthew G. Knepley #undef __FUNCT__
10042764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSInitialize_Basic"
10052764a2aaSMatthew G. Knepley PetscErrorCode PetscDSInitialize_Basic(PetscDS prob)
10062764a2aaSMatthew G. Knepley {
10072764a2aaSMatthew G. Knepley   PetscFunctionBegin;
10082764a2aaSMatthew G. Knepley   prob->ops->setfromoptions = NULL;
10092764a2aaSMatthew G. Knepley   prob->ops->setup          = NULL;
10102764a2aaSMatthew G. Knepley   prob->ops->view           = NULL;
10112764a2aaSMatthew G. Knepley   prob->ops->destroy        = PetscDSDestroy_Basic;
10122764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
10132764a2aaSMatthew G. Knepley }
10142764a2aaSMatthew G. Knepley 
10152764a2aaSMatthew G. Knepley /*MC
10162764a2aaSMatthew G. Knepley   PETSCDSBASIC = "basic" - A discrete system with pointwise residual and boundary residual functions
10172764a2aaSMatthew G. Knepley 
10182764a2aaSMatthew G. Knepley   Level: intermediate
10192764a2aaSMatthew G. Knepley 
10202764a2aaSMatthew G. Knepley .seealso: PetscDSType, PetscDSCreate(), PetscDSSetType()
10212764a2aaSMatthew G. Knepley M*/
10222764a2aaSMatthew G. Knepley 
10232764a2aaSMatthew G. Knepley #undef __FUNCT__
10242764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSCreate_Basic"
10252764a2aaSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscDSCreate_Basic(PetscDS prob)
10262764a2aaSMatthew G. Knepley {
10272764a2aaSMatthew G. Knepley   PetscDS_Basic *b;
10282764a2aaSMatthew G. Knepley   PetscErrorCode      ierr;
10292764a2aaSMatthew G. Knepley 
10302764a2aaSMatthew G. Knepley   PetscFunctionBegin;
10312764a2aaSMatthew G. Knepley   PetscValidHeaderSpecific(prob, PETSCSPACE_CLASSID, 1);
10322764a2aaSMatthew G. Knepley   ierr       = PetscNewLog(prob, &b);CHKERRQ(ierr);
10332764a2aaSMatthew G. Knepley   prob->data = b;
10342764a2aaSMatthew G. Knepley 
10352764a2aaSMatthew G. Knepley   ierr = PetscDSInitialize_Basic(prob);CHKERRQ(ierr);
10362764a2aaSMatthew G. Knepley   PetscFunctionReturn(0);
10372764a2aaSMatthew G. Knepley }
1038