xref: /petsc/src/dm/dt/interface/dtweakform.c (revision 258ec3d24857774f7a65a5963e0fabce05f6dad7)
16528b96dSMatthew G. Knepley #include <petsc/private/petscdsimpl.h> /*I "petscds.h" I*/
26528b96dSMatthew G. Knepley 
36528b96dSMatthew G. Knepley PetscClassId PETSCWEAKFORM_CLASSID = 0;
46528b96dSMatthew G. Knepley 
56528b96dSMatthew G. Knepley static PetscErrorCode PetscChunkBufferCreate(size_t unitbytes, size_t expected, PetscChunkBuffer **buffer)
66528b96dSMatthew G. Knepley {
76528b96dSMatthew G. Knepley   PetscErrorCode ierr;
86528b96dSMatthew G. Knepley 
96528b96dSMatthew G. Knepley   PetscFunctionBegin;
106528b96dSMatthew G. Knepley   ierr = PetscNew(buffer);CHKERRQ(ierr);
116528b96dSMatthew G. Knepley   ierr = PetscCalloc1(expected*unitbytes, &(*buffer)->array);CHKERRQ(ierr);
126528b96dSMatthew G. Knepley   (*buffer)->size      = expected;
136528b96dSMatthew G. Knepley   (*buffer)->unitbytes = unitbytes;
146528b96dSMatthew G. Knepley   (*buffer)->alloc     = expected*unitbytes;
156528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
166528b96dSMatthew G. Knepley }
176528b96dSMatthew G. Knepley 
1845480ffeSMatthew G. Knepley static PetscErrorCode PetscChunkBufferDuplicate(PetscChunkBuffer *buffer, PetscChunkBuffer **bufferNew)
1945480ffeSMatthew G. Knepley {
2045480ffeSMatthew G. Knepley   PetscErrorCode ierr;
2145480ffeSMatthew G. Knepley 
2245480ffeSMatthew G. Knepley   PetscFunctionBegin;
2345480ffeSMatthew G. Knepley   ierr = PetscNew(bufferNew);CHKERRQ(ierr);
2445480ffeSMatthew G. Knepley   ierr = PetscCalloc1(buffer->size*buffer->unitbytes, &(*bufferNew)->array);CHKERRQ(ierr);
2545480ffeSMatthew G. Knepley   ierr = PetscMemcpy((*bufferNew)->array, buffer->array, buffer->size*buffer->unitbytes);CHKERRQ(ierr);
2645480ffeSMatthew G. Knepley   (*bufferNew)->size      = buffer->size;
2745480ffeSMatthew G. Knepley   (*bufferNew)->unitbytes = buffer->unitbytes;
2845480ffeSMatthew G. Knepley   (*bufferNew)->alloc     = buffer->size*buffer->unitbytes;
2945480ffeSMatthew G. Knepley   PetscFunctionReturn(0);
3045480ffeSMatthew G. Knepley }
3145480ffeSMatthew G. Knepley 
326528b96dSMatthew G. Knepley static PetscErrorCode PetscChunkBufferDestroy(PetscChunkBuffer **buffer)
336528b96dSMatthew G. Knepley {
346528b96dSMatthew G. Knepley   PetscErrorCode ierr;
356528b96dSMatthew G. Knepley 
366528b96dSMatthew G. Knepley   PetscFunctionBegin;
376528b96dSMatthew G. Knepley   ierr = PetscFree((*buffer)->array);CHKERRQ(ierr);
386528b96dSMatthew G. Knepley   ierr = PetscFree(*buffer);CHKERRQ(ierr);
396528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
406528b96dSMatthew G. Knepley }
416528b96dSMatthew G. Knepley 
426528b96dSMatthew G. Knepley static PetscErrorCode PetscChunkBufferCreateChunk(PetscChunkBuffer *buffer, PetscInt size, PetscChunk *chunk)
436528b96dSMatthew G. Knepley {
446528b96dSMatthew G. Knepley   PetscErrorCode ierr;
456528b96dSMatthew G. Knepley 
466528b96dSMatthew G. Knepley   PetscFunctionBegin;
476528b96dSMatthew G. Knepley   if ((buffer->size + size)*buffer->unitbytes > buffer->alloc) {
486528b96dSMatthew G. Knepley     char *tmp;
496528b96dSMatthew G. Knepley 
506528b96dSMatthew G. Knepley     if (!buffer->alloc) buffer->alloc = (buffer->size + size)*buffer->unitbytes;
516528b96dSMatthew G. Knepley     while ((buffer->size + size)*buffer->unitbytes > buffer->alloc) buffer->alloc *= 2;
526528b96dSMatthew G. Knepley     ierr = PetscMalloc(buffer->alloc, &tmp);CHKERRQ(ierr);
536528b96dSMatthew G. Knepley     ierr = PetscMemcpy(tmp, buffer->array, buffer->size*buffer->unitbytes);CHKERRQ(ierr);
546528b96dSMatthew G. Knepley     ierr = PetscFree(buffer->array);CHKERRQ(ierr);
556528b96dSMatthew G. Knepley     buffer->array = tmp;
566528b96dSMatthew G. Knepley   }
572baeeceeSMatthew G. Knepley   chunk->start    = buffer->size*buffer->unitbytes;
586528b96dSMatthew G. Knepley   chunk->size     = size;
596528b96dSMatthew G. Knepley   chunk->reserved = size;
606528b96dSMatthew G. Knepley   buffer->size   += size;
616528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
626528b96dSMatthew G. Knepley }
636528b96dSMatthew G. Knepley 
646528b96dSMatthew G. Knepley static PetscErrorCode PetscChunkBufferEnlargeChunk(PetscChunkBuffer *buffer, PetscInt size, PetscChunk *chunk)
656528b96dSMatthew G. Knepley {
666528b96dSMatthew G. Knepley   size_t         siz = size;
676528b96dSMatthew G. Knepley   PetscErrorCode ierr;
686528b96dSMatthew G. Knepley 
696528b96dSMatthew G. Knepley   PetscFunctionBegin;
706528b96dSMatthew G. Knepley   if (chunk->size + size > chunk->reserved) {
716528b96dSMatthew G. Knepley     PetscChunk newchunk;
726528b96dSMatthew G. Knepley     PetscInt   reserved = chunk->size;
736528b96dSMatthew G. Knepley 
746528b96dSMatthew G. Knepley     /* TODO Here if we had a chunk list, we could update them all to reclaim unused space */
756528b96dSMatthew G. Knepley     while (reserved < chunk->size+size) reserved *= 2;
766528b96dSMatthew G. Knepley     ierr = PetscChunkBufferCreateChunk(buffer, (size_t) reserved, &newchunk);CHKERRQ(ierr);
776528b96dSMatthew G. Knepley     newchunk.size = chunk->size+size;
786528b96dSMatthew G. Knepley     ierr = PetscMemcpy(&buffer->array[newchunk.start], &buffer->array[chunk->start], chunk->size * buffer->unitbytes);CHKERRQ(ierr);
796528b96dSMatthew G. Knepley     *chunk = newchunk;
806528b96dSMatthew G. Knepley   } else {
816528b96dSMatthew G. Knepley     chunk->size += siz;
826528b96dSMatthew G. Knepley   }
836528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
846528b96dSMatthew G. Knepley }
856528b96dSMatthew G. Knepley 
866528b96dSMatthew G. Knepley /*@C
876528b96dSMatthew G. Knepley   PetscHashFormKeySort - Sorts an array of PetscHashFormKey in place in increasing order.
886528b96dSMatthew G. Knepley 
896528b96dSMatthew G. Knepley   Not Collective
906528b96dSMatthew G. Knepley 
916528b96dSMatthew G. Knepley   Input Parameters:
926528b96dSMatthew G. Knepley + n - number of values
936528b96dSMatthew G. Knepley - X - array of PetscHashFormKey
946528b96dSMatthew G. Knepley 
956528b96dSMatthew G. Knepley   Level: intermediate
966528b96dSMatthew G. Knepley 
976528b96dSMatthew G. Knepley .seealso: PetscIntSortSemiOrdered(), PetscSortInt()
986528b96dSMatthew G. Knepley @*/
996528b96dSMatthew G. Knepley PetscErrorCode PetscHashFormKeySort(PetscInt n, PetscHashFormKey arr[])
1006528b96dSMatthew G. Knepley {
1016528b96dSMatthew G. Knepley   PetscErrorCode ierr;
1026528b96dSMatthew G. Knepley 
1036528b96dSMatthew G. Knepley   PetscFunctionBegin;
1046528b96dSMatthew G. Knepley   if (n <= 1) PetscFunctionReturn(0);
1056528b96dSMatthew G. Knepley   PetscValidPointer(arr, 2);
1066528b96dSMatthew G. Knepley   ierr = PetscTimSort(n, arr, sizeof(PetscHashFormKey), Compare_PetscHashFormKey_Private, NULL);CHKERRQ(ierr);
1076528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
1086528b96dSMatthew G. Knepley }
1096528b96dSMatthew G. Knepley 
1106528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormGetFunction_Private(PetscWeakForm wf, PetscHMapForm ht, DMLabel label, PetscInt value, PetscInt f, PetscInt *n, void (***func)())
1116528b96dSMatthew G. Knepley {
1126528b96dSMatthew G. Knepley   PetscHashFormKey key;
1136528b96dSMatthew G. Knepley   PetscChunk       chunk;
1146528b96dSMatthew G. Knepley   PetscErrorCode   ierr;
1156528b96dSMatthew G. Knepley 
1166528b96dSMatthew G. Knepley   PetscFunctionBegin;
1176528b96dSMatthew G. Knepley   key.label = label; key.value = value; key.field = f;
1186528b96dSMatthew G. Knepley   ierr = PetscHMapFormGet(ht, key, &chunk);CHKERRQ(ierr);
1196528b96dSMatthew G. Knepley   if (chunk.size < 0) {*n = 0;          *func = NULL;}
1202baeeceeSMatthew G. Knepley   else                {*n = chunk.size; *func = (void (**)()) &wf->funcs->array[chunk.start];}
1216528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
1226528b96dSMatthew G. Knepley }
1236528b96dSMatthew G. Knepley 
1246528b96dSMatthew G. Knepley /* A NULL argument for func causes this to clear the key */
1256528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetFunction_Private(PetscWeakForm wf, PetscHMapForm ht, DMLabel label, PetscInt value, PetscInt f, PetscInt n, void (**func)())
1266528b96dSMatthew G. Knepley {
1276528b96dSMatthew G. Knepley   PetscHashFormKey key;
1286528b96dSMatthew G. Knepley   PetscChunk       chunk;
1296528b96dSMatthew G. Knepley   PetscInt         i;
1306528b96dSMatthew G. Knepley   PetscErrorCode   ierr;
1316528b96dSMatthew G. Knepley 
1326528b96dSMatthew G. Knepley   PetscFunctionBegin;
1336528b96dSMatthew G. Knepley   key.label = label; key.value = value; key.field = f;
1346528b96dSMatthew G. Knepley   if (!func) {
1356528b96dSMatthew G. Knepley     ierr = PetscHMapFormDel(ht, key);CHKERRQ(ierr);
1366528b96dSMatthew G. Knepley     PetscFunctionReturn(0);
1376528b96dSMatthew G. Knepley   } else {
1386528b96dSMatthew G. Knepley     ierr = PetscHMapFormGet(ht, key, &chunk);CHKERRQ(ierr);
1396528b96dSMatthew G. Knepley   }
1406528b96dSMatthew G. Knepley   if (chunk.size < 0) {
1416528b96dSMatthew G. Knepley     ierr = PetscChunkBufferCreateChunk(wf->funcs, n, &chunk);CHKERRQ(ierr);
1426528b96dSMatthew G. Knepley     ierr = PetscHMapFormSet(ht, key, chunk);CHKERRQ(ierr);
1436528b96dSMatthew G. Knepley   } else if (chunk.size <= n) {
1446528b96dSMatthew G. Knepley     ierr = PetscChunkBufferEnlargeChunk(wf->funcs, n - chunk.size, &chunk);CHKERRQ(ierr);
1456528b96dSMatthew G. Knepley     ierr = PetscHMapFormSet(ht, key, chunk);CHKERRQ(ierr);
1466528b96dSMatthew G. Knepley   }
1472baeeceeSMatthew G. Knepley   for (i = 0; i < n; ++i) ((void (**)()) &wf->funcs->array[chunk.start])[i] = func[i];
1486528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
1496528b96dSMatthew G. Knepley }
1506528b96dSMatthew G. Knepley 
1516528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormAddFunction_Private(PetscWeakForm wf, PetscHMapForm ht, DMLabel label, PetscInt value, PetscInt f, void (*func)())
1526528b96dSMatthew G. Knepley {
1536528b96dSMatthew G. Knepley   PetscHashFormKey key;
1546528b96dSMatthew G. Knepley   PetscChunk       chunk;
1556528b96dSMatthew G. Knepley   PetscErrorCode   ierr;
1566528b96dSMatthew G. Knepley 
1576528b96dSMatthew G. Knepley   PetscFunctionBegin;
1586528b96dSMatthew G. Knepley   if (!func) PetscFunctionReturn(0);
1596528b96dSMatthew G. Knepley   key.label = label; key.value = value; key.field = f;
1606528b96dSMatthew G. Knepley   ierr = PetscHMapFormGet(ht, key, &chunk);CHKERRQ(ierr);
1616528b96dSMatthew G. Knepley   if (chunk.size < 0) {
1626528b96dSMatthew G. Knepley     ierr = PetscChunkBufferCreateChunk(wf->funcs, 1, &chunk);CHKERRQ(ierr);
1636528b96dSMatthew G. Knepley     ierr = PetscHMapFormSet(ht, key, chunk);CHKERRQ(ierr);
1642baeeceeSMatthew G. Knepley     ((void (**)()) &wf->funcs->array[chunk.start])[0] = func;
1656528b96dSMatthew G. Knepley   } else {
1666528b96dSMatthew G. Knepley     ierr = PetscChunkBufferEnlargeChunk(wf->funcs, 1, &chunk);CHKERRQ(ierr);
1676528b96dSMatthew G. Knepley     ierr = PetscHMapFormSet(ht, key, chunk);CHKERRQ(ierr);
1682baeeceeSMatthew G. Knepley     ((void (**)()) &wf->funcs->array[chunk.start])[chunk.size-1] = func;
1696528b96dSMatthew G. Knepley   }
1706528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
1716528b96dSMatthew G. Knepley }
1726528b96dSMatthew G. Knepley 
1736528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormGetIndexFunction_Private(PetscWeakForm wf, PetscHMapForm ht, DMLabel label, PetscInt value, PetscInt f, PetscInt ind, void (**func)())
1746528b96dSMatthew G. Knepley {
1756528b96dSMatthew G. Knepley   PetscHashFormKey key;
1766528b96dSMatthew G. Knepley   PetscChunk       chunk;
1776528b96dSMatthew G. Knepley   PetscErrorCode   ierr;
1786528b96dSMatthew G. Knepley 
1796528b96dSMatthew G. Knepley   PetscFunctionBegin;
1806528b96dSMatthew G. Knepley   key.label = label; key.value = value; key.field = f;
1816528b96dSMatthew G. Knepley   ierr = PetscHMapFormGet(ht, key, &chunk);CHKERRQ(ierr);
1826528b96dSMatthew G. Knepley   if (chunk.size < 0) {*func = NULL;}
1836528b96dSMatthew G. Knepley   else {
1846528b96dSMatthew G. Knepley     if (ind >= chunk.size) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Index %D not in [0, %D)", ind, chunk.size);
1852baeeceeSMatthew G. Knepley     *func = ((void (**)()) &wf->funcs->array[chunk.start])[ind];
1866528b96dSMatthew G. Knepley   }
1876528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
1886528b96dSMatthew G. Knepley }
1896528b96dSMatthew G. Knepley 
1906528b96dSMatthew G. Knepley /* A NULL argument for func causes this to clear the slot, and if there is nothing else, clear the key */
1916528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetIndexFunction_Private(PetscWeakForm wf, PetscHMapForm ht, DMLabel label, PetscInt value, PetscInt f, PetscInt ind, void (*func)())
1926528b96dSMatthew G. Knepley {
1936528b96dSMatthew G. Knepley   PetscHashFormKey key;
1946528b96dSMatthew G. Knepley   PetscChunk       chunk;
1956528b96dSMatthew G. Knepley   PetscErrorCode   ierr;
1966528b96dSMatthew G. Knepley 
1976528b96dSMatthew G. Knepley   PetscFunctionBegin;
1986528b96dSMatthew G. Knepley   key.label = label; key.value = value; key.field = f;
1996528b96dSMatthew G. Knepley   ierr = PetscHMapFormGet(ht, key, &chunk);CHKERRQ(ierr);
2006528b96dSMatthew G. Knepley   if (chunk.size < 0) {
2016528b96dSMatthew G. Knepley     if (!func) PetscFunctionReturn(0);
2026528b96dSMatthew G. Knepley     ierr = PetscChunkBufferCreateChunk(wf->funcs, ind+1, &chunk);CHKERRQ(ierr);
2036528b96dSMatthew G. Knepley     ierr = PetscHMapFormSet(ht, key, chunk);CHKERRQ(ierr);
2046528b96dSMatthew G. Knepley   } else if (!func && !ind && chunk.size == 1) {
2056528b96dSMatthew G. Knepley     ierr = PetscHMapFormDel(ht, key);CHKERRQ(ierr);
2066528b96dSMatthew G. Knepley     PetscFunctionReturn(0);
2076528b96dSMatthew G. Knepley   } else if (chunk.size <= ind) {
2086528b96dSMatthew G. Knepley     ierr = PetscChunkBufferEnlargeChunk(wf->funcs, ind - chunk.size + 1, &chunk);CHKERRQ(ierr);
2096528b96dSMatthew G. Knepley     ierr = PetscHMapFormSet(ht, key, chunk);CHKERRQ(ierr);
2106528b96dSMatthew G. Knepley   }
2112baeeceeSMatthew G. Knepley   ((void (**)()) &wf->funcs->array[chunk.start])[ind] = func;
2126528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
2136528b96dSMatthew G. Knepley }
2146528b96dSMatthew G. Knepley 
21545480ffeSMatthew G. Knepley /*@
21645480ffeSMatthew G. Knepley   PetscWeakFormCopy - Copy the pointwise functions to another PetscWeakForm
21745480ffeSMatthew G. Knepley 
21845480ffeSMatthew G. Knepley   Not Collective
21945480ffeSMatthew G. Knepley 
22045480ffeSMatthew G. Knepley   Input Parameter:
22145480ffeSMatthew G. Knepley . wf - The original PetscWeakForm
22245480ffeSMatthew G. Knepley 
22345480ffeSMatthew G. Knepley   Output Parameter:
22445480ffeSMatthew G. Knepley . wfNew - The copy PetscWeakForm
22545480ffeSMatthew G. Knepley 
22645480ffeSMatthew G. Knepley   Level: intermediate
22745480ffeSMatthew G. Knepley 
22845480ffeSMatthew G. Knepley .seealso: PetscWeakFormCreate(), PetscWeakFormDestroy()
22945480ffeSMatthew G. Knepley @*/
23045480ffeSMatthew G. Knepley PetscErrorCode PetscWeakFormCopy(PetscWeakForm wf, PetscWeakForm wfNew)
23145480ffeSMatthew G. Knepley {
23245480ffeSMatthew G. Knepley   PetscErrorCode ierr;
23345480ffeSMatthew G. Knepley 
23445480ffeSMatthew G. Knepley   PetscFunctionBegin;
23545480ffeSMatthew G. Knepley   wfNew->Nf = wf->Nf;
23645480ffeSMatthew G. Knepley   ierr = PetscChunkBufferDestroy(&wfNew->funcs);CHKERRQ(ierr);
23745480ffeSMatthew G. Knepley   ierr = PetscChunkBufferDuplicate(wf->funcs, &wfNew->funcs);CHKERRQ(ierr);
23845480ffeSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&wfNew->obj);CHKERRQ(ierr);
23945480ffeSMatthew G. Knepley   ierr = PetscHMapFormDuplicate(wf->obj, &wfNew->obj);CHKERRQ(ierr);
24045480ffeSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&wfNew->f0);CHKERRQ(ierr);
24145480ffeSMatthew G. Knepley   ierr = PetscHMapFormDuplicate(wf->f0, &wfNew->f0);CHKERRQ(ierr);
24245480ffeSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&wfNew->f1);CHKERRQ(ierr);
24345480ffeSMatthew G. Knepley   ierr = PetscHMapFormDuplicate(wf->f1, &wfNew->f1);CHKERRQ(ierr);
24445480ffeSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&wfNew->g0);CHKERRQ(ierr);
24545480ffeSMatthew G. Knepley   ierr = PetscHMapFormDuplicate(wf->g0, &wfNew->g0);CHKERRQ(ierr);
24645480ffeSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&wfNew->g1);CHKERRQ(ierr);
24745480ffeSMatthew G. Knepley   ierr = PetscHMapFormDuplicate(wf->g1, &wfNew->g1);CHKERRQ(ierr);
24845480ffeSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&wfNew->g2);CHKERRQ(ierr);
24945480ffeSMatthew G. Knepley   ierr = PetscHMapFormDuplicate(wf->g2, &wfNew->g2);CHKERRQ(ierr);
25045480ffeSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&wfNew->g3);CHKERRQ(ierr);
25145480ffeSMatthew G. Knepley   ierr = PetscHMapFormDuplicate(wf->g3, &wfNew->g3);CHKERRQ(ierr);
25245480ffeSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&wfNew->gp0);CHKERRQ(ierr);
25345480ffeSMatthew G. Knepley   ierr = PetscHMapFormDuplicate(wf->gp0, &wfNew->gp0);CHKERRQ(ierr);
25445480ffeSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&wfNew->gp1);CHKERRQ(ierr);
25545480ffeSMatthew G. Knepley   ierr = PetscHMapFormDuplicate(wf->gp1, &wfNew->gp1);CHKERRQ(ierr);
25645480ffeSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&wfNew->gp2);CHKERRQ(ierr);
25745480ffeSMatthew G. Knepley   ierr = PetscHMapFormDuplicate(wf->gp2, &wfNew->gp2);CHKERRQ(ierr);
25845480ffeSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&wfNew->gp3);CHKERRQ(ierr);
25945480ffeSMatthew G. Knepley   ierr = PetscHMapFormDuplicate(wf->gp3, &wfNew->gp3);CHKERRQ(ierr);
26045480ffeSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&wfNew->gt0);CHKERRQ(ierr);
26145480ffeSMatthew G. Knepley   ierr = PetscHMapFormDuplicate(wf->gt0, &wfNew->gt0);CHKERRQ(ierr);
26245480ffeSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&wfNew->gt1);CHKERRQ(ierr);
26345480ffeSMatthew G. Knepley   ierr = PetscHMapFormDuplicate(wf->gt1, &wfNew->gt1);CHKERRQ(ierr);
26445480ffeSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&wfNew->gt2);CHKERRQ(ierr);
26545480ffeSMatthew G. Knepley   ierr = PetscHMapFormDuplicate(wf->gt2, &wfNew->gt2);CHKERRQ(ierr);
26645480ffeSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&wfNew->gt3);CHKERRQ(ierr);
26745480ffeSMatthew G. Knepley   ierr = PetscHMapFormDuplicate(wf->gt3, &wfNew->gt3);CHKERRQ(ierr);
26845480ffeSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&wfNew->bdf0);CHKERRQ(ierr);
26945480ffeSMatthew G. Knepley   ierr = PetscHMapFormDuplicate(wf->bdf0, &wfNew->bdf0);CHKERRQ(ierr);
27045480ffeSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&wfNew->bdf1);CHKERRQ(ierr);
27145480ffeSMatthew G. Knepley   ierr = PetscHMapFormDuplicate(wf->bdf1, &wfNew->bdf1);CHKERRQ(ierr);
27245480ffeSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&wfNew->bdg0);CHKERRQ(ierr);
27345480ffeSMatthew G. Knepley   ierr = PetscHMapFormDuplicate(wf->bdg0, &wfNew->bdg0);CHKERRQ(ierr);
27445480ffeSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&wfNew->bdg1);CHKERRQ(ierr);
27545480ffeSMatthew G. Knepley   ierr = PetscHMapFormDuplicate(wf->bdg1, &wfNew->bdg1);CHKERRQ(ierr);
27645480ffeSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&wfNew->bdg2);CHKERRQ(ierr);
27745480ffeSMatthew G. Knepley   ierr = PetscHMapFormDuplicate(wf->bdg2, &wfNew->bdg2);CHKERRQ(ierr);
27845480ffeSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&wfNew->bdg3);CHKERRQ(ierr);
27945480ffeSMatthew G. Knepley   ierr = PetscHMapFormDuplicate(wf->bdg3, &wfNew->bdg3);CHKERRQ(ierr);
28045480ffeSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&wfNew->bdgp0);CHKERRQ(ierr);
28145480ffeSMatthew G. Knepley   ierr = PetscHMapFormDuplicate(wf->bdgp0, &wfNew->bdgp0);CHKERRQ(ierr);
28245480ffeSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&wfNew->bdgp1);CHKERRQ(ierr);
28345480ffeSMatthew G. Knepley   ierr = PetscHMapFormDuplicate(wf->bdgp1, &wfNew->bdgp1);CHKERRQ(ierr);
28445480ffeSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&wfNew->bdgp2);CHKERRQ(ierr);
28545480ffeSMatthew G. Knepley   ierr = PetscHMapFormDuplicate(wf->bdgp2, &wfNew->bdgp2);CHKERRQ(ierr);
28645480ffeSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&wfNew->bdgp3);CHKERRQ(ierr);
28745480ffeSMatthew G. Knepley   ierr = PetscHMapFormDuplicate(wf->bdgp3, &wfNew->bdgp3);CHKERRQ(ierr);
28845480ffeSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&wfNew->r);CHKERRQ(ierr);
28945480ffeSMatthew G. Knepley   ierr = PetscHMapFormDuplicate(wf->r, &wfNew->r);CHKERRQ(ierr);
29045480ffeSMatthew G. Knepley   PetscFunctionReturn(0);
29145480ffeSMatthew G. Knepley }
29245480ffeSMatthew G. Knepley 
29345480ffeSMatthew G. Knepley static PetscErrorCode PetscWeakFormRewriteKeys_Internal(PetscWeakForm wf, PetscHMapForm hmap, DMLabel label, PetscInt Nv, const PetscInt values[])
29445480ffeSMatthew G. Knepley {
29545480ffeSMatthew G. Knepley   PetscHashFormKey *keys;
29645480ffeSMatthew G. Knepley   PetscInt          n, i, v, off = 0;
29745480ffeSMatthew G. Knepley   PetscErrorCode    ierr;
29845480ffeSMatthew G. Knepley 
29945480ffeSMatthew G. Knepley   PetscFunctionBegin;
30045480ffeSMatthew G. Knepley   ierr = PetscHMapFormGetSize(hmap, &n);CHKERRQ(ierr);
30145480ffeSMatthew G. Knepley   ierr = PetscMalloc1(n, &keys);CHKERRQ(ierr);
30245480ffeSMatthew G. Knepley   ierr = PetscHMapFormGetKeys(hmap, &off, keys);CHKERRQ(ierr);
30345480ffeSMatthew G. Knepley   for (i = 0; i < n; ++i) {
30445480ffeSMatthew G. Knepley     if (keys[i].label == label) {
30545480ffeSMatthew G. Knepley       PetscBool clear = PETSC_TRUE;
30645480ffeSMatthew G. Knepley       void   (**funcs)();
30745480ffeSMatthew G. Knepley       PetscInt  Nf;
30845480ffeSMatthew G. Knepley 
30945480ffeSMatthew G. Knepley       ierr = PetscWeakFormGetFunction_Private(wf, hmap, keys[i].label, keys[i].value, keys[i].field, &Nf, &funcs);CHKERRQ(ierr);
31045480ffeSMatthew G. Knepley       for (v = 0; v < Nv; ++v) {
31145480ffeSMatthew G. Knepley         ierr = PetscWeakFormSetFunction_Private(wf, hmap, keys[i].label, values[v], keys[i].field, Nf, funcs);CHKERRQ(ierr);
31245480ffeSMatthew G. Knepley         if (values[v] == keys[i].value) clear = PETSC_FALSE;
31345480ffeSMatthew G. Knepley       }
31445480ffeSMatthew G. Knepley       if (clear) {ierr = PetscWeakFormSetFunction_Private(wf, hmap, keys[i].label, keys[i].value, keys[i].field, 0, NULL);CHKERRQ(ierr);}
31545480ffeSMatthew G. Knepley     }
31645480ffeSMatthew G. Knepley   }
31745480ffeSMatthew G. Knepley   ierr = PetscFree(keys);CHKERRQ(ierr);
31845480ffeSMatthew G. Knepley   PetscFunctionReturn(0);
31945480ffeSMatthew G. Knepley }
32045480ffeSMatthew G. Knepley 
32145480ffeSMatthew G. Knepley /*@C
32245480ffeSMatthew G. Knepley   PetscWeakFormRewriteKeys - Change any key on the given label to use the new set of label values
32345480ffeSMatthew G. Knepley 
32445480ffeSMatthew G. Knepley   Not Collective
32545480ffeSMatthew G. Knepley 
32645480ffeSMatthew G. Knepley   Input Parameters:
32745480ffeSMatthew G. Knepley + wf     - The original PetscWeakForm
32845480ffeSMatthew G. Knepley . label  - The label to change keys for
32945480ffeSMatthew G. Knepley . Nv     - The number of new label values
33045480ffeSMatthew G. Knepley - values - The set of new values to relabel keys with
33145480ffeSMatthew G. Knepley 
33245480ffeSMatthew G. Knepley   Note: This is used internally when boundary label values are specified from the command line.
33345480ffeSMatthew G. Knepley 
33445480ffeSMatthew G. Knepley   Level: intermediate
33545480ffeSMatthew G. Knepley 
33645480ffeSMatthew G. Knepley .seealso: PetscWeakFormCreate(), PetscWeakFormDestroy()
33745480ffeSMatthew G. Knepley @*/
33845480ffeSMatthew G. Knepley PetscErrorCode PetscWeakFormRewriteKeys(PetscWeakForm wf, DMLabel label, PetscInt Nv, const PetscInt values[])
33945480ffeSMatthew G. Knepley {
34045480ffeSMatthew G. Knepley   PetscErrorCode ierr;
34145480ffeSMatthew G. Knepley 
34245480ffeSMatthew G. Knepley   PetscFunctionBegin;
34345480ffeSMatthew G. Knepley   ierr = PetscWeakFormRewriteKeys_Internal(wf, wf->obj,   label, Nv, values);CHKERRQ(ierr);
34445480ffeSMatthew G. Knepley   ierr = PetscWeakFormRewriteKeys_Internal(wf, wf->f0,    label, Nv, values);CHKERRQ(ierr);
34545480ffeSMatthew G. Knepley   ierr = PetscWeakFormRewriteKeys_Internal(wf, wf->f1,    label, Nv, values);CHKERRQ(ierr);
34645480ffeSMatthew G. Knepley   ierr = PetscWeakFormRewriteKeys_Internal(wf, wf->g0,    label, Nv, values);CHKERRQ(ierr);
34745480ffeSMatthew G. Knepley   ierr = PetscWeakFormRewriteKeys_Internal(wf, wf->g1,    label, Nv, values);CHKERRQ(ierr);
34845480ffeSMatthew G. Knepley   ierr = PetscWeakFormRewriteKeys_Internal(wf, wf->g2,    label, Nv, values);CHKERRQ(ierr);
34945480ffeSMatthew G. Knepley   ierr = PetscWeakFormRewriteKeys_Internal(wf, wf->g3,    label, Nv, values);CHKERRQ(ierr);
35045480ffeSMatthew G. Knepley   ierr = PetscWeakFormRewriteKeys_Internal(wf, wf->gp0,   label, Nv, values);CHKERRQ(ierr);
35145480ffeSMatthew G. Knepley   ierr = PetscWeakFormRewriteKeys_Internal(wf, wf->gp1,   label, Nv, values);CHKERRQ(ierr);
35245480ffeSMatthew G. Knepley   ierr = PetscWeakFormRewriteKeys_Internal(wf, wf->gp2,   label, Nv, values);CHKERRQ(ierr);
35345480ffeSMatthew G. Knepley   ierr = PetscWeakFormRewriteKeys_Internal(wf, wf->gp3,   label, Nv, values);CHKERRQ(ierr);
35445480ffeSMatthew G. Knepley   ierr = PetscWeakFormRewriteKeys_Internal(wf, wf->gt0,   label, Nv, values);CHKERRQ(ierr);
35545480ffeSMatthew G. Knepley   ierr = PetscWeakFormRewriteKeys_Internal(wf, wf->gt1,   label, Nv, values);CHKERRQ(ierr);
35645480ffeSMatthew G. Knepley   ierr = PetscWeakFormRewriteKeys_Internal(wf, wf->gt2,   label, Nv, values);CHKERRQ(ierr);
35745480ffeSMatthew G. Knepley   ierr = PetscWeakFormRewriteKeys_Internal(wf, wf->gt3,   label, Nv, values);CHKERRQ(ierr);
35845480ffeSMatthew G. Knepley   ierr = PetscWeakFormRewriteKeys_Internal(wf, wf->bdf0,  label, Nv, values);CHKERRQ(ierr);
35945480ffeSMatthew G. Knepley   ierr = PetscWeakFormRewriteKeys_Internal(wf, wf->bdf1,  label, Nv, values);CHKERRQ(ierr);
36045480ffeSMatthew G. Knepley   ierr = PetscWeakFormRewriteKeys_Internal(wf, wf->bdg0,  label, Nv, values);CHKERRQ(ierr);
36145480ffeSMatthew G. Knepley   ierr = PetscWeakFormRewriteKeys_Internal(wf, wf->bdg1,  label, Nv, values);CHKERRQ(ierr);
36245480ffeSMatthew G. Knepley   ierr = PetscWeakFormRewriteKeys_Internal(wf, wf->bdg2,  label, Nv, values);CHKERRQ(ierr);
36345480ffeSMatthew G. Knepley   ierr = PetscWeakFormRewriteKeys_Internal(wf, wf->bdg3,  label, Nv, values);CHKERRQ(ierr);
36445480ffeSMatthew G. Knepley   ierr = PetscWeakFormRewriteKeys_Internal(wf, wf->bdgp0, label, Nv, values);CHKERRQ(ierr);
36545480ffeSMatthew G. Knepley   ierr = PetscWeakFormRewriteKeys_Internal(wf, wf->bdgp1, label, Nv, values);CHKERRQ(ierr);
36645480ffeSMatthew G. Knepley   ierr = PetscWeakFormRewriteKeys_Internal(wf, wf->bdgp2, label, Nv, values);CHKERRQ(ierr);
36745480ffeSMatthew G. Knepley   ierr = PetscWeakFormRewriteKeys_Internal(wf, wf->bdgp3, label, Nv, values);CHKERRQ(ierr);
36845480ffeSMatthew G. Knepley   ierr = PetscWeakFormRewriteKeys_Internal(wf, wf->r,     label, Nv, values);CHKERRQ(ierr);
36945480ffeSMatthew G. Knepley   PetscFunctionReturn(0);
37045480ffeSMatthew G. Knepley }
37145480ffeSMatthew G. Knepley 
3726528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormGetObjective(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt *n,
3736528b96dSMatthew G. Knepley                                          void (***obj)(PetscInt, PetscInt, PetscInt,
3746528b96dSMatthew G. Knepley                                                        const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
3756528b96dSMatthew G. Knepley                                                        const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
3766528b96dSMatthew G. Knepley                                                        PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
3776528b96dSMatthew G. Knepley {
3786528b96dSMatthew G. Knepley   PetscErrorCode ierr;
3796528b96dSMatthew G. Knepley 
3806528b96dSMatthew G. Knepley   PetscFunctionBegin;
3816528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->obj, label, val, f, n, (void (***)(void)) obj);CHKERRQ(ierr);
3826528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
3836528b96dSMatthew G. Knepley }
3846528b96dSMatthew G. Knepley 
3856528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetObjective(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt n,
3866528b96dSMatthew G. Knepley                                          void (**obj)(PetscInt, PetscInt, PetscInt,
3876528b96dSMatthew G. Knepley                                                       const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const  PetscScalar[],
3886528b96dSMatthew G. Knepley                                                       const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
3896528b96dSMatthew G. Knepley                                                       PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
3906528b96dSMatthew G. Knepley {
3916528b96dSMatthew G. Knepley   PetscErrorCode ierr;
3926528b96dSMatthew G. Knepley 
3936528b96dSMatthew G. Knepley   PetscFunctionBegin;
3946528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->obj, label, val, f, n, (void (**)(void)) obj);CHKERRQ(ierr);
3956528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
3966528b96dSMatthew G. Knepley }
3976528b96dSMatthew G. Knepley 
3986528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormAddObjective(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f,
3996528b96dSMatthew G. Knepley                                          void (*obj)(PetscInt, PetscInt, PetscInt,
4006528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4016528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4026528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
4036528b96dSMatthew G. Knepley {
4046528b96dSMatthew G. Knepley   PetscErrorCode ierr;
4056528b96dSMatthew G. Knepley 
4066528b96dSMatthew G. Knepley   PetscFunctionBegin;
4076528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->obj, label, val, f, (void (*)(void)) obj);CHKERRQ(ierr);
4086528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
4096528b96dSMatthew G. Knepley }
4106528b96dSMatthew G. Knepley 
4116528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormGetIndexObjective(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt ind,
4126528b96dSMatthew G. Knepley                                               void (**obj)(PetscInt, PetscInt, PetscInt,
4136528b96dSMatthew G. Knepley                                                            const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4146528b96dSMatthew G. Knepley                                                            const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4156528b96dSMatthew G. Knepley                                                            PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
4166528b96dSMatthew G. Knepley {
4176528b96dSMatthew G. Knepley   PetscErrorCode ierr;
4186528b96dSMatthew G. Knepley 
4196528b96dSMatthew G. Knepley   PetscFunctionBegin;
4206528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetIndexFunction_Private(wf, wf->obj, label, val, f, ind, (void (**)(void)) obj);CHKERRQ(ierr);
4216528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
4226528b96dSMatthew G. Knepley }
4236528b96dSMatthew G. Knepley 
4246528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetIndexObjective(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt ind,
4256528b96dSMatthew G. Knepley                                               void (*obj)(PetscInt, PetscInt, PetscInt,
4266528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4276528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4286528b96dSMatthew G. Knepley                                                           PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
4296528b96dSMatthew G. Knepley {
4306528b96dSMatthew G. Knepley   PetscErrorCode ierr;
4316528b96dSMatthew G. Knepley 
4326528b96dSMatthew G. Knepley   PetscFunctionBegin;
4336528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->obj, label, val, f, ind, (void (*)(void)) obj);CHKERRQ(ierr);
4346528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
4356528b96dSMatthew G. Knepley }
4366528b96dSMatthew G. Knepley 
4376528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormGetResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f,
4386528b96dSMatthew G. Knepley                                         PetscInt *n0,
4396528b96dSMatthew G. Knepley                                         void (***f0)(PetscInt, PetscInt, PetscInt,
4406528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4416528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4426528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
4436528b96dSMatthew G. Knepley                                         PetscInt *n1,
4446528b96dSMatthew G. Knepley                                         void (***f1)(PetscInt, PetscInt, PetscInt,
4456528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4466528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4476528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
4486528b96dSMatthew G. Knepley {
4496528b96dSMatthew G. Knepley   PetscErrorCode ierr;
4506528b96dSMatthew G. Knepley 
4516528b96dSMatthew G. Knepley   PetscFunctionBegin;
4526528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->f0, label, val, f, n0, (void (***)(void)) f0);CHKERRQ(ierr);
4536528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->f1, label, val, f, n1, (void (***)(void)) f1);CHKERRQ(ierr);
4546528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
4556528b96dSMatthew G. Knepley }
4566528b96dSMatthew G. Knepley 
4576528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormAddResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f,
4586528b96dSMatthew G. Knepley                                         void (*f0)(PetscInt, PetscInt, PetscInt,
4596528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4606528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4616528b96dSMatthew G. Knepley                                                    PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
4626528b96dSMatthew G. Knepley                                         void (*f1)(PetscInt, PetscInt, PetscInt,
4636528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4646528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4656528b96dSMatthew G. Knepley                                                    PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
4666528b96dSMatthew G. Knepley {
4676528b96dSMatthew G. Knepley   PetscErrorCode ierr;
4686528b96dSMatthew G. Knepley 
4696528b96dSMatthew G. Knepley   PetscFunctionBegin;
4706528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->f0, label, val, f, (void (*)(void)) f0);CHKERRQ(ierr);
4716528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->f1, label, val, f, (void (*)(void)) f1);CHKERRQ(ierr);
4726528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
4736528b96dSMatthew G. Knepley }
4746528b96dSMatthew G. Knepley 
4756528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f,
4766528b96dSMatthew G. Knepley                                         PetscInt n0,
4776528b96dSMatthew G. Knepley                                         void (**f0)(PetscInt, PetscInt, PetscInt,
4786528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4796528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4806528b96dSMatthew G. Knepley                                                    PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
4816528b96dSMatthew G. Knepley                                         PetscInt n1,
4826528b96dSMatthew G. Knepley                                         void (**f1)(PetscInt, PetscInt, PetscInt,
4836528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4846528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4856528b96dSMatthew G. Knepley                                                    PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
4866528b96dSMatthew G. Knepley {
4876528b96dSMatthew G. Knepley   PetscErrorCode ierr;
4886528b96dSMatthew G. Knepley 
4896528b96dSMatthew G. Knepley   PetscFunctionBegin;
4906528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->f0, label, val, f, n0, (void (**)(void)) f0);CHKERRQ(ierr);
4916528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->f1, label, val, f, n1, (void (**)(void)) f1);CHKERRQ(ierr);
4926528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
4936528b96dSMatthew G. Knepley }
4946528b96dSMatthew G. Knepley 
4956528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetIndexResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f,
4966528b96dSMatthew G. Knepley                                         PetscInt i0,
4976528b96dSMatthew G. Knepley                                         void (*f0)(PetscInt, PetscInt, PetscInt,
4986528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4996528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5006528b96dSMatthew G. Knepley                                                    PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
5016528b96dSMatthew G. Knepley                                         PetscInt i1,
5026528b96dSMatthew G. Knepley                                         void (*f1)(PetscInt, PetscInt, PetscInt,
5036528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5046528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5056528b96dSMatthew G. Knepley                                                    PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
5066528b96dSMatthew G. Knepley {
5076528b96dSMatthew G. Knepley   PetscErrorCode ierr;
5086528b96dSMatthew G. Knepley 
5096528b96dSMatthew G. Knepley   PetscFunctionBegin;
5106528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->f0, label, val, f, i0, (void (*)(void)) f0);CHKERRQ(ierr);
5116528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->f1, label, val, f, i1, (void (*)(void)) f1);CHKERRQ(ierr);
5126528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
5136528b96dSMatthew G. Knepley }
5146528b96dSMatthew G. Knepley 
5156528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormGetBdResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f,
5166528b96dSMatthew G. Knepley                                           PetscInt *n0,
5176528b96dSMatthew G. Knepley                                         void (***f0)(PetscInt, PetscInt, PetscInt,
5186528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5196528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5206528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
5216528b96dSMatthew G. Knepley                                         PetscInt *n1,
5226528b96dSMatthew G. Knepley                                         void (***f1)(PetscInt, PetscInt, PetscInt,
5236528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5246528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5256528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
5266528b96dSMatthew G. Knepley {
5276528b96dSMatthew G. Knepley   PetscErrorCode ierr;
5286528b96dSMatthew G. Knepley 
5296528b96dSMatthew G. Knepley   PetscFunctionBegin;
5306528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->bdf0, label, val, f, n0, (void (***)(void)) f0);CHKERRQ(ierr);
5316528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->bdf1, label, val, f, n1, (void (***)(void)) f1);CHKERRQ(ierr);
5326528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
5336528b96dSMatthew G. Knepley }
5346528b96dSMatthew G. Knepley 
5356528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormAddBdResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f,
5366528b96dSMatthew G. Knepley                                           void (*f0)(PetscInt, PetscInt, PetscInt,
5376528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5386528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5396528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
5406528b96dSMatthew G. Knepley                                           void (*f1)(PetscInt, PetscInt, PetscInt,
5416528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5426528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5436528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
5446528b96dSMatthew G. Knepley {
5456528b96dSMatthew G. Knepley   PetscErrorCode ierr;
5466528b96dSMatthew G. Knepley 
5476528b96dSMatthew G. Knepley   PetscFunctionBegin;
5486528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->bdf0, label, val, f, (void (*)(void)) f0);CHKERRQ(ierr);
5496528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->bdf1, label, val, f, (void (*)(void)) f1);CHKERRQ(ierr);
5506528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
5516528b96dSMatthew G. Knepley }
5526528b96dSMatthew G. Knepley 
5536528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetBdResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f,
5546528b96dSMatthew G. Knepley                                           PetscInt n0,
5556528b96dSMatthew G. Knepley                                           void (**f0)(PetscInt, PetscInt, PetscInt,
5566528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5576528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5586528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
5596528b96dSMatthew G. Knepley                                           PetscInt n1,
5606528b96dSMatthew G. Knepley                                           void (**f1)(PetscInt, PetscInt, PetscInt,
5616528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5626528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5636528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
5646528b96dSMatthew G. Knepley {
5656528b96dSMatthew G. Knepley   PetscErrorCode ierr;
5666528b96dSMatthew G. Knepley 
5676528b96dSMatthew G. Knepley   PetscFunctionBegin;
5686528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->bdf0, label, val, f, n0, (void (**)(void)) f0);CHKERRQ(ierr);
5696528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->bdf1, label, val, f, n1, (void (**)(void)) f1);CHKERRQ(ierr);
5706528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
5716528b96dSMatthew G. Knepley }
5726528b96dSMatthew G. Knepley 
5736528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetIndexBdResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f,
5746528b96dSMatthew G. Knepley                                           PetscInt i0,
5756528b96dSMatthew G. Knepley                                           void (*f0)(PetscInt, PetscInt, PetscInt,
5766528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5776528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5786528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
5796528b96dSMatthew G. Knepley                                           PetscInt i1,
5806528b96dSMatthew G. Knepley                                           void (*f1)(PetscInt, PetscInt, PetscInt,
5816528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5826528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5836528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
5846528b96dSMatthew G. Knepley {
5856528b96dSMatthew G. Knepley   PetscErrorCode ierr;
5866528b96dSMatthew G. Knepley 
5876528b96dSMatthew G. Knepley   PetscFunctionBegin;
5886528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->bdf0, label, val, f, i0, (void (*)(void)) f0);CHKERRQ(ierr);
5896528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->bdf1, label, val, f, i1, (void (*)(void)) f1);CHKERRQ(ierr);
5906528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
5916528b96dSMatthew G. Knepley }
5926528b96dSMatthew G. Knepley 
5936528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormHasJacobian(PetscWeakForm wf, PetscBool *hasJac)
5946528b96dSMatthew G. Knepley {
5956528b96dSMatthew G. Knepley   PetscInt       n0, n1, n2, n3;
5966528b96dSMatthew G. Knepley   PetscErrorCode ierr;
5976528b96dSMatthew G. Knepley 
5986528b96dSMatthew G. Knepley   PetscFunctionBegin;
5996528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
6006528b96dSMatthew G. Knepley   PetscValidBoolPointer(hasJac, 2);
6016528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->g0, &n0);CHKERRQ(ierr);
6026528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->g1, &n1);CHKERRQ(ierr);
6036528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->g2, &n2);CHKERRQ(ierr);
6046528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->g3, &n3);CHKERRQ(ierr);
6056528b96dSMatthew G. Knepley   *hasJac = n0+n1+n2+n3 ? PETSC_TRUE : PETSC_FALSE;
6066528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
6076528b96dSMatthew G. Knepley }
6086528b96dSMatthew G. Knepley 
6096528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormGetJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
6106528b96dSMatthew G. Knepley                                         PetscInt *n0,
6116528b96dSMatthew G. Knepley                                         void (***g0)(PetscInt, PetscInt, PetscInt,
6126528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6136528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6146528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
6156528b96dSMatthew G. Knepley                                         PetscInt *n1,
6166528b96dSMatthew G. Knepley                                         void (***g1)(PetscInt, PetscInt, PetscInt,
6176528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6186528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6196528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
6206528b96dSMatthew G. Knepley                                         PetscInt *n2,
6216528b96dSMatthew G. Knepley                                         void (***g2)(PetscInt, PetscInt, PetscInt,
6226528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6236528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6246528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
6256528b96dSMatthew G. Knepley                                         PetscInt *n3,
6266528b96dSMatthew G. Knepley                                         void (***g3)(PetscInt, PetscInt, PetscInt,
6276528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6286528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6296528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
6306528b96dSMatthew G. Knepley {
6316528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
6326528b96dSMatthew G. Knepley   PetscErrorCode ierr;
6336528b96dSMatthew G. Knepley 
6346528b96dSMatthew G. Knepley   PetscFunctionBegin;
6356528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->g0, label, val, find, n0, (void (***)(void)) g0);CHKERRQ(ierr);
6366528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->g1, label, val, find, n1, (void (***)(void)) g1);CHKERRQ(ierr);
6376528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->g2, label, val, find, n2, (void (***)(void)) g2);CHKERRQ(ierr);
6386528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->g3, label, val, find, n3, (void (***)(void)) g3);CHKERRQ(ierr);
6396528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
6406528b96dSMatthew G. Knepley }
6416528b96dSMatthew G. Knepley 
6426528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormAddJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
6436528b96dSMatthew G. Knepley                                         void (*g0)(PetscInt, PetscInt, PetscInt,
6446528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6456528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6466528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
6476528b96dSMatthew G. Knepley                                         void (*g1)(PetscInt, PetscInt, PetscInt,
6486528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6496528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6506528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
6516528b96dSMatthew G. Knepley                                         void (*g2)(PetscInt, PetscInt, PetscInt,
6526528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6536528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6546528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
6556528b96dSMatthew G. Knepley                                         void (*g3)(PetscInt, PetscInt, PetscInt,
6566528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6576528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6586528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
6596528b96dSMatthew G. Knepley {
6606528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
6616528b96dSMatthew G. Knepley   PetscErrorCode ierr;
6626528b96dSMatthew G. Knepley 
6636528b96dSMatthew G. Knepley   PetscFunctionBegin;
6646528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->g0, label, val, find, (void (*)(void)) g0);CHKERRQ(ierr);
6656528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->g1, label, val, find, (void (*)(void)) g1);CHKERRQ(ierr);
6666528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->g2, label, val, find, (void (*)(void)) g2);CHKERRQ(ierr);
6676528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->g3, label, val, find, (void (*)(void)) g3);CHKERRQ(ierr);
6686528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
6696528b96dSMatthew G. Knepley }
6706528b96dSMatthew G. Knepley 
6716528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
6726528b96dSMatthew G. Knepley                                         PetscInt n0,
6736528b96dSMatthew G. Knepley                                         void (**g0)(PetscInt, PetscInt, PetscInt,
6746528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6756528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6766528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
6776528b96dSMatthew G. Knepley                                         PetscInt n1,
6786528b96dSMatthew G. Knepley                                         void (**g1)(PetscInt, PetscInt, PetscInt,
6796528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6806528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6816528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
6826528b96dSMatthew G. Knepley                                         PetscInt n2,
6836528b96dSMatthew G. Knepley                                         void (**g2)(PetscInt, PetscInt, PetscInt,
6846528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6856528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6866528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
6876528b96dSMatthew G. Knepley                                         PetscInt n3,
6886528b96dSMatthew G. Knepley                                         void (**g3)(PetscInt, PetscInt, PetscInt,
6896528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6906528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6916528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
6926528b96dSMatthew G. Knepley {
6936528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
6946528b96dSMatthew G. Knepley   PetscErrorCode ierr;
6956528b96dSMatthew G. Knepley 
6966528b96dSMatthew G. Knepley   PetscFunctionBegin;
6976528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->g0, label, val, find, n0, (void (**)(void)) g0);CHKERRQ(ierr);
6986528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->g1, label, val, find, n1, (void (**)(void)) g1);CHKERRQ(ierr);
6996528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->g2, label, val, find, n2, (void (**)(void)) g2);CHKERRQ(ierr);
7006528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->g3, label, val, find, n3, (void (**)(void)) g3);CHKERRQ(ierr);
7016528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
7026528b96dSMatthew G. Knepley }
7036528b96dSMatthew G. Knepley 
7046528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetIndexJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
7056528b96dSMatthew G. Knepley                                         PetscInt i0,
7066528b96dSMatthew G. Knepley                                         void (*g0)(PetscInt, PetscInt, PetscInt,
7076528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7086528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7096528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
7106528b96dSMatthew G. Knepley                                         PetscInt i1,
7116528b96dSMatthew G. Knepley                                         void (*g1)(PetscInt, PetscInt, PetscInt,
7126528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7136528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7146528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
7156528b96dSMatthew G. Knepley                                         PetscInt i2,
7166528b96dSMatthew G. Knepley                                         void (*g2)(PetscInt, PetscInt, PetscInt,
7176528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7186528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7196528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
7206528b96dSMatthew G. Knepley                                         PetscInt i3,
7216528b96dSMatthew G. Knepley                                         void (*g3)(PetscInt, PetscInt, PetscInt,
7226528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7236528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7246528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
7256528b96dSMatthew G. Knepley {
7266528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
7276528b96dSMatthew G. Knepley   PetscErrorCode ierr;
7286528b96dSMatthew G. Knepley 
7296528b96dSMatthew G. Knepley   PetscFunctionBegin;
7306528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->g0, label, val, find, i0, (void (*)(void)) g0);CHKERRQ(ierr);
7316528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->g1, label, val, find, i1, (void (*)(void)) g1);CHKERRQ(ierr);
7326528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->g2, label, val, find, i2, (void (*)(void)) g2);CHKERRQ(ierr);
7336528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->g3, label, val, find, i3, (void (*)(void)) g3);CHKERRQ(ierr);
7346528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
7356528b96dSMatthew G. Knepley }
7366528b96dSMatthew G. Knepley 
7376528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormHasJacobianPreconditioner(PetscWeakForm wf, PetscBool *hasJacPre)
7386528b96dSMatthew G. Knepley {
7396528b96dSMatthew G. Knepley   PetscInt       n0, n1, n2, n3;
7406528b96dSMatthew G. Knepley   PetscErrorCode ierr;
7416528b96dSMatthew G. Knepley 
7426528b96dSMatthew G. Knepley   PetscFunctionBegin;
7436528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
7446528b96dSMatthew G. Knepley   PetscValidBoolPointer(hasJacPre, 2);
7456528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->gp0, &n0);CHKERRQ(ierr);
7466528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->gp1, &n1);CHKERRQ(ierr);
7476528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->gp2, &n2);CHKERRQ(ierr);
7486528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->gp3, &n3);CHKERRQ(ierr);
7496528b96dSMatthew G. Knepley   *hasJacPre = n0+n1+n2+n3 ? PETSC_TRUE : PETSC_FALSE;
7506528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
7516528b96dSMatthew G. Knepley }
7526528b96dSMatthew G. Knepley 
7536528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormGetJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
7546528b96dSMatthew G. Knepley                                                       PetscInt *n0,
7556528b96dSMatthew G. Knepley                                                       void (***g0)(PetscInt, PetscInt, PetscInt,
7566528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7576528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7586528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
7596528b96dSMatthew G. Knepley                                                       PetscInt *n1,
7606528b96dSMatthew G. Knepley                                                       void (***g1)(PetscInt, PetscInt, PetscInt,
7616528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7626528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7636528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
7646528b96dSMatthew G. Knepley                                                       PetscInt *n2,
7656528b96dSMatthew G. Knepley                                                       void (***g2)(PetscInt, PetscInt, PetscInt,
7666528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7676528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7686528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
7696528b96dSMatthew G. Knepley                                                       PetscInt *n3,
7706528b96dSMatthew G. Knepley                                                       void (***g3)(PetscInt, PetscInt, PetscInt,
7716528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7726528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7736528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
7746528b96dSMatthew G. Knepley {
7756528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
7766528b96dSMatthew G. Knepley   PetscErrorCode ierr;
7776528b96dSMatthew G. Knepley 
7786528b96dSMatthew G. Knepley   PetscFunctionBegin;
7796528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->gp0, label, val, find, n0, (void (***)(void)) g0);CHKERRQ(ierr);
7806528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->gp1, label, val, find, n1, (void (***)(void)) g1);CHKERRQ(ierr);
7816528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->gp2, label, val, find, n2, (void (***)(void)) g2);CHKERRQ(ierr);
7826528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->gp3, label, val, find, n3, (void (***)(void)) g3);CHKERRQ(ierr);
7836528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
7846528b96dSMatthew G. Knepley }
7856528b96dSMatthew G. Knepley 
7866528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormAddJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
7876528b96dSMatthew G. Knepley                                         void (*g0)(PetscInt, PetscInt, PetscInt,
7886528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7896528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7906528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
7916528b96dSMatthew G. Knepley                                         void (*g1)(PetscInt, PetscInt, PetscInt,
7926528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7936528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7946528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
7956528b96dSMatthew G. Knepley                                         void (*g2)(PetscInt, PetscInt, PetscInt,
7966528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7976528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7986528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
7996528b96dSMatthew G. Knepley                                         void (*g3)(PetscInt, PetscInt, PetscInt,
8006528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8016528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8026528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
8036528b96dSMatthew G. Knepley {
8046528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
8056528b96dSMatthew G. Knepley   PetscErrorCode ierr;
8066528b96dSMatthew G. Knepley 
8076528b96dSMatthew G. Knepley   PetscFunctionBegin;
8086528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->gp0, label, val, find, (void (*)(void)) g0);CHKERRQ(ierr);
8096528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->gp1, label, val, find, (void (*)(void)) g1);CHKERRQ(ierr);
8106528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->gp2, label, val, find, (void (*)(void)) g2);CHKERRQ(ierr);
8116528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->gp3, label, val, find, (void (*)(void)) g3);CHKERRQ(ierr);
8126528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
8136528b96dSMatthew G. Knepley }
8146528b96dSMatthew G. Knepley 
8156528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
8166528b96dSMatthew G. Knepley                                                       PetscInt n0,
8176528b96dSMatthew G. Knepley                                                       void (**g0)(PetscInt, PetscInt, PetscInt,
8186528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8196528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8206528b96dSMatthew G. Knepley                                                                  PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
8216528b96dSMatthew G. Knepley                                                       PetscInt n1,
8226528b96dSMatthew G. Knepley                                                       void (**g1)(PetscInt, PetscInt, PetscInt,
8236528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8246528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8256528b96dSMatthew G. Knepley                                                                  PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
8266528b96dSMatthew G. Knepley                                                       PetscInt n2,
8276528b96dSMatthew G. Knepley                                                       void (**g2)(PetscInt, PetscInt, PetscInt,
8286528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8296528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8306528b96dSMatthew G. Knepley                                                                  PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
8316528b96dSMatthew G. Knepley                                                       PetscInt n3,
8326528b96dSMatthew G. Knepley                                                       void (**g3)(PetscInt, PetscInt, PetscInt,
8336528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8346528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8356528b96dSMatthew G. Knepley                                                                  PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
8366528b96dSMatthew G. Knepley {
8376528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
8386528b96dSMatthew G. Knepley   PetscErrorCode ierr;
8396528b96dSMatthew G. Knepley 
8406528b96dSMatthew G. Knepley   PetscFunctionBegin;
8416528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->gp0, label, val, find, n0, (void (**)(void)) g0);CHKERRQ(ierr);
8426528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->gp1, label, val, find, n1, (void (**)(void)) g1);CHKERRQ(ierr);
8436528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->gp2, label, val, find, n2, (void (**)(void)) g2);CHKERRQ(ierr);
8446528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->gp3, label, val, find, n3, (void (**)(void)) g3);CHKERRQ(ierr);
8456528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
8466528b96dSMatthew G. Knepley }
8476528b96dSMatthew G. Knepley 
8486528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetIndexJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
8496528b96dSMatthew G. Knepley                                                       PetscInt i0,
8506528b96dSMatthew G. Knepley                                                       void (*g0)(PetscInt, PetscInt, PetscInt,
8516528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8526528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8536528b96dSMatthew G. Knepley                                                                  PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
8546528b96dSMatthew G. Knepley                                                       PetscInt i1,
8556528b96dSMatthew G. Knepley                                                       void (*g1)(PetscInt, PetscInt, PetscInt,
8566528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8576528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8586528b96dSMatthew G. Knepley                                                                  PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
8596528b96dSMatthew G. Knepley                                                       PetscInt i2,
8606528b96dSMatthew G. Knepley                                                       void (*g2)(PetscInt, PetscInt, PetscInt,
8616528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8626528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8636528b96dSMatthew G. Knepley                                                                  PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
8646528b96dSMatthew G. Knepley                                                       PetscInt i3,
8656528b96dSMatthew G. Knepley                                                       void (*g3)(PetscInt, PetscInt, PetscInt,
8666528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8676528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8686528b96dSMatthew G. Knepley                                                                  PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
8696528b96dSMatthew G. Knepley {
8706528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
8716528b96dSMatthew G. Knepley   PetscErrorCode ierr;
8726528b96dSMatthew G. Knepley 
8736528b96dSMatthew G. Knepley   PetscFunctionBegin;
8746528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->gp0, label, val, find, i0, (void (*)(void)) g0);CHKERRQ(ierr);
8756528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->gp1, label, val, find, i1, (void (*)(void)) g1);CHKERRQ(ierr);
8766528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->gp2, label, val, find, i2, (void (*)(void)) g2);CHKERRQ(ierr);
8776528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->gp3, label, val, find, i3, (void (*)(void)) g3);CHKERRQ(ierr);
8786528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
8796528b96dSMatthew G. Knepley }
8806528b96dSMatthew G. Knepley 
8816528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormHasBdJacobian(PetscWeakForm wf, PetscBool *hasJac)
8826528b96dSMatthew G. Knepley {
8836528b96dSMatthew G. Knepley   PetscInt       n0, n1, n2, n3;
8846528b96dSMatthew G. Knepley   PetscErrorCode ierr;
8856528b96dSMatthew G. Knepley 
8866528b96dSMatthew G. Knepley   PetscFunctionBegin;
8876528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
8886528b96dSMatthew G. Knepley   PetscValidBoolPointer(hasJac, 2);
8896528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->bdg0, &n0);CHKERRQ(ierr);
8906528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->bdg1, &n1);CHKERRQ(ierr);
8916528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->bdg2, &n2);CHKERRQ(ierr);
8926528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->bdg3, &n3);CHKERRQ(ierr);
8936528b96dSMatthew G. Knepley   *hasJac = n0+n1+n2+n3 ? PETSC_TRUE : PETSC_FALSE;
8946528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
8956528b96dSMatthew G. Knepley }
8966528b96dSMatthew G. Knepley 
8976528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormGetBdJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
8986528b96dSMatthew G. Knepley                                           PetscInt *n0,
8996528b96dSMatthew G. Knepley                                           void (***g0)(PetscInt, PetscInt, PetscInt,
9006528b96dSMatthew G. Knepley                                                        const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9016528b96dSMatthew G. Knepley                                                        const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9026528b96dSMatthew G. Knepley                                                        PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
9036528b96dSMatthew G. Knepley                                           PetscInt *n1,
9046528b96dSMatthew G. Knepley                                           void (***g1)(PetscInt, PetscInt, PetscInt,
9056528b96dSMatthew G. Knepley                                                        const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9066528b96dSMatthew G. Knepley                                                        const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9076528b96dSMatthew G. Knepley                                                        PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
9086528b96dSMatthew G. Knepley                                           PetscInt *n2,
9096528b96dSMatthew G. Knepley                                           void (***g2)(PetscInt, PetscInt, PetscInt,
9106528b96dSMatthew G. Knepley                                                        const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9116528b96dSMatthew G. Knepley                                                        const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9126528b96dSMatthew G. Knepley                                                        PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
9136528b96dSMatthew G. Knepley                                           PetscInt *n3,
9146528b96dSMatthew G. Knepley                                           void (***g3)(PetscInt, PetscInt, PetscInt,
9156528b96dSMatthew G. Knepley                                                        const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9166528b96dSMatthew G. Knepley                                                        const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9176528b96dSMatthew G. Knepley                                                        PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
9186528b96dSMatthew G. Knepley {
9196528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
9206528b96dSMatthew G. Knepley   PetscErrorCode ierr;
9216528b96dSMatthew G. Knepley 
9226528b96dSMatthew G. Knepley   PetscFunctionBegin;
9236528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->bdg0, label, val, find, n0, (void (***)(void)) g0);CHKERRQ(ierr);
9246528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->bdg1, label, val, find, n1, (void (***)(void)) g1);CHKERRQ(ierr);
9256528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->bdg2, label, val, find, n2, (void (***)(void)) g2);CHKERRQ(ierr);
9266528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->bdg3, label, val, find, n3, (void (***)(void)) g3);CHKERRQ(ierr);
9276528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
9286528b96dSMatthew G. Knepley }
9296528b96dSMatthew G. Knepley 
9306528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormAddBdJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
9316528b96dSMatthew G. Knepley                                           void (*g0)(PetscInt, PetscInt, PetscInt,
9326528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9336528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9346528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
9356528b96dSMatthew G. Knepley                                           void (*g1)(PetscInt, PetscInt, PetscInt,
9366528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9376528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9386528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
9396528b96dSMatthew G. Knepley                                           void (*g2)(PetscInt, PetscInt, PetscInt,
9406528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9416528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9426528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
9436528b96dSMatthew G. Knepley                                           void (*g3)(PetscInt, PetscInt, PetscInt,
9446528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9456528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9466528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
9476528b96dSMatthew G. Knepley {
9486528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
9496528b96dSMatthew G. Knepley   PetscErrorCode ierr;
9506528b96dSMatthew G. Knepley 
9516528b96dSMatthew G. Knepley   PetscFunctionBegin;
9526528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->bdg0, label, val, find, (void (*)(void)) g0);CHKERRQ(ierr);
9536528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->bdg1, label, val, find, (void (*)(void)) g1);CHKERRQ(ierr);
9546528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->bdg2, label, val, find, (void (*)(void)) g2);CHKERRQ(ierr);
9556528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->bdg3, label, val, find, (void (*)(void)) g3);CHKERRQ(ierr);
9566528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
9576528b96dSMatthew G. Knepley }
9586528b96dSMatthew G. Knepley 
9596528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetBdJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
9606528b96dSMatthew G. Knepley                                           PetscInt n0,
9616528b96dSMatthew G. Knepley                                           void (**g0)(PetscInt, PetscInt, PetscInt,
9626528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9636528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9646528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
9656528b96dSMatthew G. Knepley                                           PetscInt n1,
9666528b96dSMatthew G. Knepley                                           void (**g1)(PetscInt, PetscInt, PetscInt,
9676528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9686528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9696528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
9706528b96dSMatthew G. Knepley                                           PetscInt n2,
9716528b96dSMatthew G. Knepley                                           void (**g2)(PetscInt, PetscInt, PetscInt,
9726528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9736528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9746528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
9756528b96dSMatthew G. Knepley                                           PetscInt n3,
9766528b96dSMatthew G. Knepley                                           void (**g3)(PetscInt, PetscInt, PetscInt,
9776528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9786528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9796528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
9806528b96dSMatthew G. Knepley {
9816528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
9826528b96dSMatthew G. Knepley   PetscErrorCode ierr;
9836528b96dSMatthew G. Knepley 
9846528b96dSMatthew G. Knepley   PetscFunctionBegin;
9856528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->bdg0, label, val, find, n0, (void (**)(void)) g0);CHKERRQ(ierr);
9866528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->bdg1, label, val, find, n1, (void (**)(void)) g1);CHKERRQ(ierr);
9876528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->bdg2, label, val, find, n2, (void (**)(void)) g2);CHKERRQ(ierr);
9886528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->bdg3, label, val, find, n3, (void (**)(void)) g3);CHKERRQ(ierr);
9896528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
9906528b96dSMatthew G. Knepley }
9916528b96dSMatthew G. Knepley 
9926528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetIndexBdJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
9936528b96dSMatthew G. Knepley                                           PetscInt i0,
9946528b96dSMatthew G. Knepley                                           void (*g0)(PetscInt, PetscInt, PetscInt,
9956528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9966528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9976528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
9986528b96dSMatthew G. Knepley                                           PetscInt i1,
9996528b96dSMatthew G. Knepley                                           void (*g1)(PetscInt, PetscInt, PetscInt,
10006528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10016528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10026528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
10036528b96dSMatthew G. Knepley                                           PetscInt i2,
10046528b96dSMatthew G. Knepley                                           void (*g2)(PetscInt, PetscInt, PetscInt,
10056528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10066528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10076528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
10086528b96dSMatthew G. Knepley                                           PetscInt i3,
10096528b96dSMatthew G. Knepley                                           void (*g3)(PetscInt, PetscInt, PetscInt,
10106528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10116528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10126528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
10136528b96dSMatthew G. Knepley {
10146528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
10156528b96dSMatthew G. Knepley   PetscErrorCode ierr;
10166528b96dSMatthew G. Knepley 
10176528b96dSMatthew G. Knepley   PetscFunctionBegin;
10186528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->bdg0, label, val, find, i0, (void (*)(void)) g0);CHKERRQ(ierr);
10196528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->bdg1, label, val, find, i1, (void (*)(void)) g1);CHKERRQ(ierr);
10206528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->bdg2, label, val, find, i2, (void (*)(void)) g2);CHKERRQ(ierr);
10216528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->bdg3, label, val, find, i3, (void (*)(void)) g3);CHKERRQ(ierr);
10226528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
10236528b96dSMatthew G. Knepley }
10246528b96dSMatthew G. Knepley 
10256528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormHasBdJacobianPreconditioner(PetscWeakForm wf, PetscBool *hasJacPre)
10266528b96dSMatthew G. Knepley {
10276528b96dSMatthew G. Knepley   PetscInt       n0, n1, n2, n3;
10286528b96dSMatthew G. Knepley   PetscErrorCode ierr;
10296528b96dSMatthew G. Knepley 
10306528b96dSMatthew G. Knepley   PetscFunctionBegin;
10316528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
10326528b96dSMatthew G. Knepley   PetscValidBoolPointer(hasJacPre, 2);
10336528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->bdgp0, &n0);CHKERRQ(ierr);
10346528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->bdgp1, &n1);CHKERRQ(ierr);
10356528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->bdgp2, &n2);CHKERRQ(ierr);
10366528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->bdgp3, &n3);CHKERRQ(ierr);
10376528b96dSMatthew G. Knepley   *hasJacPre = n0+n1+n2+n3 ? PETSC_TRUE : PETSC_FALSE;
10386528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
10396528b96dSMatthew G. Knepley }
10406528b96dSMatthew G. Knepley 
10416528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormGetBdJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
10426528b96dSMatthew G. Knepley                                                         PetscInt *n0,
10436528b96dSMatthew G. Knepley                                                         void (***g0)(PetscInt, PetscInt, PetscInt,
10446528b96dSMatthew G. Knepley                                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10456528b96dSMatthew G. Knepley                                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10466528b96dSMatthew G. Knepley                                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
10476528b96dSMatthew G. Knepley                                                         PetscInt *n1,
10486528b96dSMatthew G. Knepley                                                         void (***g1)(PetscInt, PetscInt, PetscInt,
10496528b96dSMatthew G. Knepley                                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10506528b96dSMatthew G. Knepley                                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10516528b96dSMatthew G. Knepley                                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
10526528b96dSMatthew G. Knepley                                                         PetscInt *n2,
10536528b96dSMatthew G. Knepley                                                         void (***g2)(PetscInt, PetscInt, PetscInt,
10546528b96dSMatthew G. Knepley                                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10556528b96dSMatthew G. Knepley                                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10566528b96dSMatthew G. Knepley                                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
10576528b96dSMatthew G. Knepley                                                         PetscInt *n3,
10586528b96dSMatthew G. Knepley                                                         void (***g3)(PetscInt, PetscInt, PetscInt,
10596528b96dSMatthew G. Knepley                                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10606528b96dSMatthew G. Knepley                                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10616528b96dSMatthew G. Knepley                                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
10626528b96dSMatthew G. Knepley {
10636528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
10646528b96dSMatthew G. Knepley   PetscErrorCode ierr;
10656528b96dSMatthew G. Knepley 
10666528b96dSMatthew G. Knepley   PetscFunctionBegin;
10676528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->bdgp0, label, val, find, n0, (void (***)(void)) g0);CHKERRQ(ierr);
10686528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->bdgp1, label, val, find, n1, (void (***)(void)) g1);CHKERRQ(ierr);
10696528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->bdgp2, label, val, find, n2, (void (***)(void)) g2);CHKERRQ(ierr);
10706528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->bdgp3, label, val, find, n3, (void (***)(void)) g3);CHKERRQ(ierr);
10716528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
10726528b96dSMatthew G. Knepley }
10736528b96dSMatthew G. Knepley 
10746528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormAddBdJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
10756528b96dSMatthew G. Knepley                                                         void (*g0)(PetscInt, PetscInt, PetscInt,
10766528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10776528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10786528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
10796528b96dSMatthew G. Knepley                                                         void (*g1)(PetscInt, PetscInt, PetscInt,
10806528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10816528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10826528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
10836528b96dSMatthew G. Knepley                                                         void (*g2)(PetscInt, PetscInt, PetscInt,
10846528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10856528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10866528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
10876528b96dSMatthew G. Knepley                                                         void (*g3)(PetscInt, PetscInt, PetscInt,
10886528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10896528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10906528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
10916528b96dSMatthew G. Knepley {
10926528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
10936528b96dSMatthew G. Knepley   PetscErrorCode ierr;
10946528b96dSMatthew G. Knepley 
10956528b96dSMatthew G. Knepley   PetscFunctionBegin;
10966528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->bdgp0, label, val, find, (void (*)(void)) g0);CHKERRQ(ierr);
10976528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->bdgp1, label, val, find, (void (*)(void)) g1);CHKERRQ(ierr);
10986528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->bdgp2, label, val, find, (void (*)(void)) g2);CHKERRQ(ierr);
10996528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->bdgp3, label, val, find, (void (*)(void)) g3);CHKERRQ(ierr);
11006528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
11016528b96dSMatthew G. Knepley }
11026528b96dSMatthew G. Knepley 
11036528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetBdJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
11046528b96dSMatthew G. Knepley                                                         PetscInt n0,
11056528b96dSMatthew G. Knepley                                                         void (**g0)(PetscInt, PetscInt, PetscInt,
11066528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11076528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11086528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
11096528b96dSMatthew G. Knepley                                                         PetscInt n1,
11106528b96dSMatthew G. Knepley                                                         void (**g1)(PetscInt, PetscInt, PetscInt,
11116528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11126528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11136528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
11146528b96dSMatthew G. Knepley                                                         PetscInt n2,
11156528b96dSMatthew G. Knepley                                                         void (**g2)(PetscInt, PetscInt, PetscInt,
11166528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11176528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11186528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
11196528b96dSMatthew G. Knepley                                                         PetscInt n3,
11206528b96dSMatthew G. Knepley                                                         void (**g3)(PetscInt, PetscInt, PetscInt,
11216528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11226528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11236528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
11246528b96dSMatthew G. Knepley {
11256528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
11266528b96dSMatthew G. Knepley   PetscErrorCode ierr;
11276528b96dSMatthew G. Knepley 
11286528b96dSMatthew G. Knepley   PetscFunctionBegin;
11296528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->bdgp0, label, val, find, n0, (void (**)(void)) g0);CHKERRQ(ierr);
11306528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->bdgp1, label, val, find, n1, (void (**)(void)) g1);CHKERRQ(ierr);
11316528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->bdgp2, label, val, find, n2, (void (**)(void)) g2);CHKERRQ(ierr);
11326528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->bdgp3, label, val, find, n3, (void (**)(void)) g3);CHKERRQ(ierr);
11336528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
11346528b96dSMatthew G. Knepley }
11356528b96dSMatthew G. Knepley 
11366528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetIndexBdJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
11376528b96dSMatthew G. Knepley                                                         PetscInt i0,
11386528b96dSMatthew G. Knepley                                                         void (*g0)(PetscInt, PetscInt, PetscInt,
11396528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11406528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11416528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
11426528b96dSMatthew G. Knepley                                                         PetscInt i1,
11436528b96dSMatthew G. Knepley                                                         void (*g1)(PetscInt, PetscInt, PetscInt,
11446528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11456528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11466528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
11476528b96dSMatthew G. Knepley                                                         PetscInt i2,
11486528b96dSMatthew G. Knepley                                                         void (*g2)(PetscInt, PetscInt, PetscInt,
11496528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11506528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11516528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
11526528b96dSMatthew G. Knepley                                                         PetscInt i3,
11536528b96dSMatthew G. Knepley                                                         void (*g3)(PetscInt, PetscInt, PetscInt,
11546528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11556528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11566528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
11576528b96dSMatthew G. Knepley {
11586528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
11596528b96dSMatthew G. Knepley   PetscErrorCode ierr;
11606528b96dSMatthew G. Knepley 
11616528b96dSMatthew G. Knepley   PetscFunctionBegin;
11626528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->bdgp0, label, val, find, i0, (void (*)(void)) g0);CHKERRQ(ierr);
11636528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->bdgp1, label, val, find, i1, (void (*)(void)) g1);CHKERRQ(ierr);
11646528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->bdgp2, label, val, find, i2, (void (*)(void)) g2);CHKERRQ(ierr);
11656528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->bdgp3, label, val, find, i3, (void (*)(void)) g3);CHKERRQ(ierr);
11666528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
11676528b96dSMatthew G. Knepley }
11686528b96dSMatthew G. Knepley 
11696528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormHasDynamicJacobian(PetscWeakForm wf, PetscBool *hasDynJac)
11706528b96dSMatthew G. Knepley {
11716528b96dSMatthew G. Knepley   PetscInt       n0, n1, n2, n3;
11726528b96dSMatthew G. Knepley   PetscErrorCode ierr;
11736528b96dSMatthew G. Knepley 
11746528b96dSMatthew G. Knepley   PetscFunctionBegin;
11756528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
11766528b96dSMatthew G. Knepley   PetscValidBoolPointer(hasDynJac, 2);
11776528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->gt0, &n0);CHKERRQ(ierr);
11786528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->gt1, &n1);CHKERRQ(ierr);
11796528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->gt2, &n2);CHKERRQ(ierr);
11806528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->gt3, &n3);CHKERRQ(ierr);
11816528b96dSMatthew G. Knepley   *hasDynJac = n0+n1+n2+n3 ? PETSC_TRUE : PETSC_FALSE;
11826528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
11836528b96dSMatthew G. Knepley }
11846528b96dSMatthew G. Knepley 
11856528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormGetDynamicJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
11866528b96dSMatthew G. Knepley                                         PetscInt *n0,
11876528b96dSMatthew G. Knepley                                         void (***g0)(PetscInt, PetscInt, PetscInt,
11886528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11896528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11906528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
11916528b96dSMatthew G. Knepley                                         PetscInt *n1,
11926528b96dSMatthew G. Knepley                                         void (***g1)(PetscInt, PetscInt, PetscInt,
11936528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11946528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11956528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
11966528b96dSMatthew G. Knepley                                         PetscInt *n2,
11976528b96dSMatthew G. Knepley                                         void (***g2)(PetscInt, PetscInt, PetscInt,
11986528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11996528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12006528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
12016528b96dSMatthew G. Knepley                                         PetscInt *n3,
12026528b96dSMatthew G. Knepley                                         void (***g3)(PetscInt, PetscInt, PetscInt,
12036528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12046528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12056528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
12066528b96dSMatthew G. Knepley {
12076528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
12086528b96dSMatthew G. Knepley   PetscErrorCode ierr;
12096528b96dSMatthew G. Knepley 
12106528b96dSMatthew G. Knepley   PetscFunctionBegin;
12116528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->gt0, label, val, find, n0, (void (***)(void)) g0);CHKERRQ(ierr);
12126528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->gt1, label, val, find, n1, (void (***)(void)) g1);CHKERRQ(ierr);
12136528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->gt2, label, val, find, n2, (void (***)(void)) g2);CHKERRQ(ierr);
12146528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->gt3, label, val, find, n3, (void (***)(void)) g3);CHKERRQ(ierr);
12156528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
12166528b96dSMatthew G. Knepley }
12176528b96dSMatthew G. Knepley 
12186528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormAddDynamicJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
12196528b96dSMatthew G. Knepley                                         void (*g0)(PetscInt, PetscInt, PetscInt,
12206528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12216528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12226528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
12236528b96dSMatthew G. Knepley                                         void (*g1)(PetscInt, PetscInt, PetscInt,
12246528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12256528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12266528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
12276528b96dSMatthew G. Knepley                                         void (*g2)(PetscInt, PetscInt, PetscInt,
12286528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12296528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12306528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
12316528b96dSMatthew G. Knepley                                         void (*g3)(PetscInt, PetscInt, PetscInt,
12326528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12336528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12346528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
12356528b96dSMatthew G. Knepley {
12366528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
12376528b96dSMatthew G. Knepley   PetscErrorCode ierr;
12386528b96dSMatthew G. Knepley 
12396528b96dSMatthew G. Knepley   PetscFunctionBegin;
12406528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->gt0, label, val, find, (void (*)(void)) g0);CHKERRQ(ierr);
12416528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->gt1, label, val, find, (void (*)(void)) g1);CHKERRQ(ierr);
12426528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->gt2, label, val, find, (void (*)(void)) g2);CHKERRQ(ierr);
12436528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->gt3, label, val, find, (void (*)(void)) g3);CHKERRQ(ierr);
12446528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
12456528b96dSMatthew G. Knepley }
12466528b96dSMatthew G. Knepley 
12476528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetDynamicJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
12486528b96dSMatthew G. Knepley                                                PetscInt n0,
12496528b96dSMatthew G. Knepley                                                void (**g0)(PetscInt, PetscInt, PetscInt,
12506528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12516528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12526528b96dSMatthew G. Knepley                                                           PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
12536528b96dSMatthew G. Knepley                                                PetscInt n1,
12546528b96dSMatthew G. Knepley                                                void (**g1)(PetscInt, PetscInt, PetscInt,
12556528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12566528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12576528b96dSMatthew G. Knepley                                                           PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
12586528b96dSMatthew G. Knepley                                                PetscInt n2,
12596528b96dSMatthew G. Knepley                                                void (**g2)(PetscInt, PetscInt, PetscInt,
12606528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12616528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12626528b96dSMatthew G. Knepley                                                           PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
12636528b96dSMatthew G. Knepley                                                PetscInt n3,
12646528b96dSMatthew G. Knepley                                                void (**g3)(PetscInt, PetscInt, PetscInt,
12656528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12666528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12676528b96dSMatthew G. Knepley                                                           PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
12686528b96dSMatthew G. Knepley {
12696528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
12706528b96dSMatthew G. Knepley   PetscErrorCode ierr;
12716528b96dSMatthew G. Knepley 
12726528b96dSMatthew G. Knepley   PetscFunctionBegin;
12736528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->gt0, label, val, find, n0, (void (**)(void)) g0);CHKERRQ(ierr);
12746528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->gt1, label, val, find, n1, (void (**)(void)) g1);CHKERRQ(ierr);
12756528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->gt2, label, val, find, n2, (void (**)(void)) g2);CHKERRQ(ierr);
12766528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->gt3, label, val, find, n3, (void (**)(void)) g3);CHKERRQ(ierr);
12776528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
12786528b96dSMatthew G. Knepley }
12796528b96dSMatthew G. Knepley 
12806528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetIndexDynamicJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
12816528b96dSMatthew G. Knepley                                                PetscInt i0,
12826528b96dSMatthew G. Knepley                                                void (*g0)(PetscInt, PetscInt, PetscInt,
12836528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12846528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12856528b96dSMatthew G. Knepley                                                           PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
12866528b96dSMatthew G. Knepley                                                PetscInt i1,
12876528b96dSMatthew G. Knepley                                                void (*g1)(PetscInt, PetscInt, PetscInt,
12886528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12896528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12906528b96dSMatthew G. Knepley                                                           PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
12916528b96dSMatthew G. Knepley                                                PetscInt i2,
12926528b96dSMatthew G. Knepley                                                void (*g2)(PetscInt, PetscInt, PetscInt,
12936528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12946528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12956528b96dSMatthew G. Knepley                                                           PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
12966528b96dSMatthew G. Knepley                                                PetscInt i3,
12976528b96dSMatthew G. Knepley                                                void (*g3)(PetscInt, PetscInt, PetscInt,
12986528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12996528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
13006528b96dSMatthew G. Knepley                                                           PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
13016528b96dSMatthew G. Knepley {
13026528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
13036528b96dSMatthew G. Knepley   PetscErrorCode ierr;
13046528b96dSMatthew G. Knepley 
13056528b96dSMatthew G. Knepley   PetscFunctionBegin;
13066528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->gt0, label, val, find, i0, (void (*)(void)) g0);CHKERRQ(ierr);
13076528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->gt1, label, val, find, i1, (void (*)(void)) g1);CHKERRQ(ierr);
13086528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->gt2, label, val, find, i2, (void (*)(void)) g2);CHKERRQ(ierr);
13096528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->gt3, label, val, find, i3, (void (*)(void)) g3);CHKERRQ(ierr);
13106528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
13116528b96dSMatthew G. Knepley }
13126528b96dSMatthew G. Knepley 
13136528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormGetRiemannSolver(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt *n,
13146528b96dSMatthew G. Knepley                                              void (***r)(PetscInt, PetscInt, const PetscReal[], const PetscReal[], const PetscScalar[], const PetscScalar[], PetscInt, const PetscScalar[], PetscScalar[], void *))
13156528b96dSMatthew G. Knepley {
13166528b96dSMatthew G. Knepley   PetscErrorCode ierr;
13176528b96dSMatthew G. Knepley 
13186528b96dSMatthew G. Knepley   PetscFunctionBegin;
13196528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->r, label, val, f, n, (void (***)(void)) r);CHKERRQ(ierr);
13206528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
13216528b96dSMatthew G. Knepley }
13226528b96dSMatthew G. Knepley 
13236528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetRiemannSolver(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f,
13246528b96dSMatthew G. Knepley                                              PetscInt n,
13256528b96dSMatthew G. Knepley                                              void (**r)(PetscInt, PetscInt, const PetscReal[], const PetscReal[], const PetscScalar[], const PetscScalar[], PetscInt, const PetscScalar[], PetscScalar[], void *))
13266528b96dSMatthew G. Knepley {
13276528b96dSMatthew G. Knepley   PetscErrorCode ierr;
13286528b96dSMatthew G. Knepley 
13296528b96dSMatthew G. Knepley   PetscFunctionBegin;
13306528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->r, label, val, f, n, (void (**)(void)) r);CHKERRQ(ierr);
13316528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
13326528b96dSMatthew G. Knepley }
13336528b96dSMatthew G. Knepley 
13346528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetIndexRiemannSolver(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f,
13356528b96dSMatthew G. Knepley                                                   PetscInt i,
13366528b96dSMatthew G. Knepley                                                   void (*r)(PetscInt, PetscInt, const PetscReal[], const PetscReal[], const PetscScalar[], const PetscScalar[], PetscInt, const PetscScalar[], PetscScalar[], void *))
13376528b96dSMatthew G. Knepley {
13386528b96dSMatthew G. Knepley   PetscErrorCode ierr;
13396528b96dSMatthew G. Knepley 
13406528b96dSMatthew G. Knepley   PetscFunctionBegin;
13416528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->r, label, val, f, i, (void (*)(void)) r);CHKERRQ(ierr);
13426528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
13436528b96dSMatthew G. Knepley }
13446528b96dSMatthew G. Knepley 
13456528b96dSMatthew G. Knepley /*@
13466528b96dSMatthew G. Knepley   PetscWeakFormGetNumFields - Returns the number of fields
13476528b96dSMatthew G. Knepley 
13486528b96dSMatthew G. Knepley   Not collective
13496528b96dSMatthew G. Knepley 
13506528b96dSMatthew G. Knepley   Input Parameter:
13516528b96dSMatthew G. Knepley . wf - The PetscWeakForm object
13526528b96dSMatthew G. Knepley 
13536528b96dSMatthew G. Knepley   Output Parameter:
13546528b96dSMatthew G. Knepley . Nf - The nubmer of fields
13556528b96dSMatthew G. Knepley 
13566528b96dSMatthew G. Knepley   Level: beginner
13576528b96dSMatthew G. Knepley 
13586528b96dSMatthew G. Knepley .seealso: PetscWeakFormSetNumFields(), PetscWeakFormCreate()
13596528b96dSMatthew G. Knepley @*/
13606528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormGetNumFields(PetscWeakForm wf, PetscInt *Nf)
13616528b96dSMatthew G. Knepley {
13626528b96dSMatthew G. Knepley   PetscFunctionBegin;
13636528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
13646528b96dSMatthew G. Knepley   PetscValidPointer(Nf, 2);
13656528b96dSMatthew G. Knepley   *Nf = wf->Nf;
13666528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
13676528b96dSMatthew G. Knepley }
13686528b96dSMatthew G. Knepley 
13696528b96dSMatthew G. Knepley /*@
13706528b96dSMatthew G. Knepley   PetscWeakFormSetNumFields - Sets the number of fields
13716528b96dSMatthew G. Knepley 
13726528b96dSMatthew G. Knepley   Not collective
13736528b96dSMatthew G. Knepley 
13746528b96dSMatthew G. Knepley   Input Parameters:
13756528b96dSMatthew G. Knepley + wf - The PetscWeakForm object
13766528b96dSMatthew G. Knepley - Nf - The number of fields
13776528b96dSMatthew G. Knepley 
13786528b96dSMatthew G. Knepley   Level: beginner
13796528b96dSMatthew G. Knepley 
13806528b96dSMatthew G. Knepley .seealso: PetscWeakFormGetNumFields(), PetscWeakFormCreate()
13816528b96dSMatthew G. Knepley @*/
13826528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetNumFields(PetscWeakForm wf, PetscInt Nf)
13836528b96dSMatthew G. Knepley {
13846528b96dSMatthew G. Knepley   PetscFunctionBegin;
13856528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
13866528b96dSMatthew G. Knepley   wf->Nf = Nf;
13876528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
13886528b96dSMatthew G. Knepley }
13896528b96dSMatthew G. Knepley 
13906528b96dSMatthew G. Knepley /*@
13916528b96dSMatthew G. Knepley   PetscWeakFormDestroy - Destroys a PetscWeakForm object
13926528b96dSMatthew G. Knepley 
13936528b96dSMatthew G. Knepley   Collective on wf
13946528b96dSMatthew G. Knepley 
13956528b96dSMatthew G. Knepley   Input Parameter:
13966528b96dSMatthew G. Knepley . wf - the PetscWeakForm object to destroy
13976528b96dSMatthew G. Knepley 
13986528b96dSMatthew G. Knepley   Level: developer
13996528b96dSMatthew G. Knepley 
14006528b96dSMatthew G. Knepley .seealso PetscWeakFormCreate(), PetscWeakFormView()
14016528b96dSMatthew G. Knepley @*/
14026528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormDestroy(PetscWeakForm *wf)
14036528b96dSMatthew G. Knepley {
14046528b96dSMatthew G. Knepley   PetscErrorCode ierr;
14056528b96dSMatthew G. Knepley 
14066528b96dSMatthew G. Knepley   PetscFunctionBegin;
14076528b96dSMatthew G. Knepley   if (!*wf) PetscFunctionReturn(0);
14086528b96dSMatthew G. Knepley   PetscValidHeaderSpecific((*wf), PETSCWEAKFORM_CLASSID, 1);
14096528b96dSMatthew G. Knepley 
14106528b96dSMatthew G. Knepley   if (--((PetscObject)(*wf))->refct > 0) {*wf = NULL; PetscFunctionReturn(0);}
14116528b96dSMatthew G. Knepley   ((PetscObject) (*wf))->refct = 0;
14126528b96dSMatthew G. Knepley   ierr = PetscChunkBufferDestroy(&(*wf)->funcs);CHKERRQ(ierr);
14136528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->obj);CHKERRQ(ierr);
14146528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->f0);CHKERRQ(ierr);
14156528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->f1);CHKERRQ(ierr);
14166528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->g0);CHKERRQ(ierr);
14176528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->g1);CHKERRQ(ierr);
14186528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->g2);CHKERRQ(ierr);
14196528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->g3);CHKERRQ(ierr);
14206528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->gp0);CHKERRQ(ierr);
14216528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->gp1);CHKERRQ(ierr);
14226528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->gp2);CHKERRQ(ierr);
14236528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->gp3);CHKERRQ(ierr);
14246528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->gt0);CHKERRQ(ierr);
14256528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->gt1);CHKERRQ(ierr);
14266528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->gt2);CHKERRQ(ierr);
14276528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->gt3);CHKERRQ(ierr);
14286528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->bdf0);CHKERRQ(ierr);
14296528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->bdf1);CHKERRQ(ierr);
14306528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->bdg0);CHKERRQ(ierr);
14316528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->bdg1);CHKERRQ(ierr);
14326528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->bdg2);CHKERRQ(ierr);
14336528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->bdg3);CHKERRQ(ierr);
14346528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->bdgp0);CHKERRQ(ierr);
14356528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->bdgp1);CHKERRQ(ierr);
14366528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->bdgp2);CHKERRQ(ierr);
14376528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->bdgp3);CHKERRQ(ierr);
14386528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->r);CHKERRQ(ierr);
14396528b96dSMatthew G. Knepley   ierr = PetscHeaderDestroy(wf);CHKERRQ(ierr);
14406528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
14416528b96dSMatthew G. Knepley }
14426528b96dSMatthew G. Knepley 
144345480ffeSMatthew G. Knepley static PetscErrorCode PetscWeakFormViewTable_Ascii(PetscWeakForm wf, PetscViewer viewer, PetscBool splitField, const char tableName[], PetscHMapForm map)
14446528b96dSMatthew G. Knepley {
144545480ffeSMatthew G. Knepley   PetscInt       Nf = wf->Nf, Nk, k;
14466528b96dSMatthew G. Knepley   PetscErrorCode ierr;
14476528b96dSMatthew G. Knepley 
14486528b96dSMatthew G. Knepley   PetscFunctionBegin;
14496528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(map, &Nk);CHKERRQ(ierr);
14506528b96dSMatthew G. Knepley   if (Nk) {
14516528b96dSMatthew G. Knepley     PetscHashFormKey *keys;
14526528b96dSMatthew G. Knepley     void           (**funcs)(void);
14536528b96dSMatthew G. Knepley     const char       *name;
14546528b96dSMatthew G. Knepley     PetscInt          off = 0, n, i;
14556528b96dSMatthew G. Knepley 
14566528b96dSMatthew G. Knepley     ierr = PetscMalloc1(Nk, &keys);CHKERRQ(ierr);
14576528b96dSMatthew G. Knepley     ierr = PetscHMapFormGetKeys(map, &off, keys);CHKERRQ(ierr);
14586528b96dSMatthew G. Knepley     ierr = PetscViewerASCIIPrintf(viewer, "%s\n", tableName);CHKERRQ(ierr);
14596528b96dSMatthew G. Knepley     ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr);
14606528b96dSMatthew G. Knepley     for (k = 0; k < Nk; ++k) {
146145480ffeSMatthew G. Knepley       if (keys[k].label) {
146245480ffeSMatthew G. Knepley         ierr = PetscObjectGetName((PetscObject) keys[k].label, &name);CHKERRQ(ierr);
146345480ffeSMatthew G. Knepley         ierr = PetscViewerASCIIPrintf(viewer, "(%s, %D) ", name, keys[k].value);CHKERRQ(ierr);
146445480ffeSMatthew G. Knepley       } else {ierr = PetscViewerASCIIPrintf(viewer, "");CHKERRQ(ierr);}
14656528b96dSMatthew G. Knepley       ierr = PetscViewerASCIIUseTabs(viewer, PETSC_FALSE);CHKERRQ(ierr);
146645480ffeSMatthew G. Knepley       if (splitField) {ierr = PetscViewerASCIIPrintf(viewer, "(%D, %D) ", keys[k].field/Nf, keys[k].field%Nf);CHKERRQ(ierr);}
146745480ffeSMatthew G. Knepley       else            {ierr = PetscViewerASCIIPrintf(viewer, "(%D) ", keys[k].field);CHKERRQ(ierr);}
14686528b96dSMatthew G. Knepley       ierr = PetscWeakFormGetFunction_Private(wf, map, keys[k].label, keys[k].value, keys[k].field, &n, &funcs);CHKERRQ(ierr);
14696528b96dSMatthew G. Knepley       for (i = 0; i < n; ++i) {
1470*258ec3d2SMatthew G. Knepley         char *fname;
1471*258ec3d2SMatthew G. Knepley 
14726528b96dSMatthew G. Knepley         if (i > 0) {ierr = PetscViewerASCIIPrintf(viewer, ", ");CHKERRQ(ierr);}
1473*258ec3d2SMatthew G. Knepley         ierr = PetscDLAddr(funcs[i], &fname);CHKERRQ(ierr);
1474*258ec3d2SMatthew G. Knepley         if (fname) {ierr = PetscViewerASCIIPrintf(viewer, "%s", fname);CHKERRQ(ierr);}
14756528b96dSMatthew G. Knepley         else       {ierr = PetscViewerASCIIPrintf(viewer, "%p", funcs[i]);CHKERRQ(ierr);}
1476*258ec3d2SMatthew G. Knepley         ierr = PetscFree(fname);CHKERRQ(ierr);
14776528b96dSMatthew G. Knepley       }
14786528b96dSMatthew G. Knepley       ierr = PetscViewerASCIIPrintf(viewer, "\n");CHKERRQ(ierr);
14796528b96dSMatthew G. Knepley       ierr = PetscViewerASCIIUseTabs(viewer, PETSC_TRUE);CHKERRQ(ierr);
14806528b96dSMatthew G. Knepley     }
14816528b96dSMatthew G. Knepley     ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr);
14826528b96dSMatthew G. Knepley     ierr = PetscFree(keys);CHKERRQ(ierr);
14836528b96dSMatthew G. Knepley   }
14846528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
14856528b96dSMatthew G. Knepley }
14866528b96dSMatthew G. Knepley 
14876528b96dSMatthew G. Knepley static PetscErrorCode PetscWeakFormView_Ascii(PetscWeakForm wf, PetscViewer viewer)
14886528b96dSMatthew G. Knepley {
14896528b96dSMatthew G. Knepley   PetscViewerFormat format;
14906528b96dSMatthew G. Knepley   PetscErrorCode    ierr;
14916528b96dSMatthew G. Knepley 
14926528b96dSMatthew G. Knepley   PetscFunctionBegin;
14936528b96dSMatthew G. Knepley   ierr = PetscViewerGetFormat(viewer, &format);CHKERRQ(ierr);
14946528b96dSMatthew G. Knepley   ierr = PetscViewerASCIIPrintf(viewer, "Weak Form System with %d fields\n", wf->Nf);CHKERRQ(ierr);
14956528b96dSMatthew G. Knepley   ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr);
149645480ffeSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, PETSC_FALSE, "Objective", wf->obj);CHKERRQ(ierr);
149745480ffeSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, PETSC_FALSE, "Residual f0", wf->f0);CHKERRQ(ierr);
149845480ffeSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, PETSC_FALSE, "Residual f1", wf->f1);CHKERRQ(ierr);
149945480ffeSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, PETSC_FALSE, "Boundary Residual f0", wf->bdf0);CHKERRQ(ierr);
150045480ffeSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, PETSC_FALSE, "Boundary Residual f1", wf->bdf1);CHKERRQ(ierr);
150145480ffeSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, PETSC_TRUE,  "Jacobian g0", wf->g0);CHKERRQ(ierr);
150245480ffeSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, PETSC_TRUE,  "Jacobian g1", wf->g1);CHKERRQ(ierr);
150345480ffeSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, PETSC_TRUE,  "Jacobian g2", wf->g2);CHKERRQ(ierr);
150445480ffeSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, PETSC_TRUE,  "Jacobian g3", wf->g3);CHKERRQ(ierr);
150545480ffeSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, PETSC_TRUE,  "Jacobian Preconditioner g0", wf->gp0);CHKERRQ(ierr);
150645480ffeSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, PETSC_TRUE,  "Jacobian Preconditioner g1", wf->gp1);CHKERRQ(ierr);
150745480ffeSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, PETSC_TRUE,  "Jacobian Preconditioner g2", wf->gp2);CHKERRQ(ierr);
150845480ffeSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, PETSC_TRUE,  "Jacobian Preconditioner g3", wf->gp3);CHKERRQ(ierr);
150945480ffeSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, PETSC_TRUE,  "Dynamic Jacobian g0", wf->gt0);CHKERRQ(ierr);
151045480ffeSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, PETSC_TRUE,  "Dynamic Jacobian g1", wf->gt1);CHKERRQ(ierr);
151145480ffeSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, PETSC_TRUE,  "Dynamic Jacobian g2", wf->gt2);CHKERRQ(ierr);
151245480ffeSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, PETSC_TRUE,  "Dynamic Jacobian g3", wf->gt3);CHKERRQ(ierr);
151345480ffeSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, PETSC_TRUE,  "Boundary Jacobian g0", wf->bdg0);CHKERRQ(ierr);
151445480ffeSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, PETSC_TRUE,  "Boundary Jacobian g1", wf->bdg1);CHKERRQ(ierr);
151545480ffeSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, PETSC_TRUE,  "Boundary Jacobian g2", wf->bdg2);CHKERRQ(ierr);
151645480ffeSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, PETSC_TRUE,  "Boundary Jacobian g3", wf->bdg3);CHKERRQ(ierr);
151745480ffeSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, PETSC_TRUE,  "Boundary Jacobian Preconditioner g0", wf->bdgp0);CHKERRQ(ierr);
151845480ffeSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, PETSC_TRUE,  "Boundary Jacobian Preconditioner g1", wf->bdgp1);CHKERRQ(ierr);
151945480ffeSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, PETSC_TRUE,  "Boundary Jacobian Preconditioner g2", wf->bdgp2);CHKERRQ(ierr);
152045480ffeSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, PETSC_TRUE,  "Boundary Jacobian Preconditioner g3", wf->bdgp3);CHKERRQ(ierr);
152145480ffeSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, PETSC_FALSE, "Riemann Solver", wf->r);CHKERRQ(ierr);
15226528b96dSMatthew G. Knepley   ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr);
15236528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
15246528b96dSMatthew G. Knepley }
15256528b96dSMatthew G. Knepley 
15266528b96dSMatthew G. Knepley /*@C
15276528b96dSMatthew G. Knepley   PetscWeakFormView - Views a PetscWeakForm
15286528b96dSMatthew G. Knepley 
15296528b96dSMatthew G. Knepley   Collective on wf
15306528b96dSMatthew G. Knepley 
15316528b96dSMatthew G. Knepley   Input Parameter:
15326528b96dSMatthew G. Knepley + wf - the PetscWeakForm object to view
15336528b96dSMatthew G. Knepley - v  - the viewer
15346528b96dSMatthew G. Knepley 
15356528b96dSMatthew G. Knepley   Level: developer
15366528b96dSMatthew G. Knepley 
15376528b96dSMatthew G. Knepley .seealso PetscWeakFormDestroy(), PetscWeakFormCreate()
15386528b96dSMatthew G. Knepley @*/
15396528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormView(PetscWeakForm wf, PetscViewer v)
15406528b96dSMatthew G. Knepley {
15416528b96dSMatthew G. Knepley   PetscBool      iascii;
15426528b96dSMatthew G. Knepley   PetscErrorCode ierr;
15436528b96dSMatthew G. Knepley 
15446528b96dSMatthew G. Knepley   PetscFunctionBegin;
15456528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
15466528b96dSMatthew G. Knepley   if (!v) {ierr = PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject) wf), &v);CHKERRQ(ierr);}
15476528b96dSMatthew G. Knepley   else    {PetscValidHeaderSpecific(v, PETSC_VIEWER_CLASSID, 2);}
15486528b96dSMatthew G. Knepley   ierr = PetscObjectTypeCompare((PetscObject) v, PETSCVIEWERASCII, &iascii);CHKERRQ(ierr);
15496528b96dSMatthew G. Knepley   if (iascii) {ierr = PetscWeakFormView_Ascii(wf, v);CHKERRQ(ierr);}
15506528b96dSMatthew G. Knepley   if (wf->ops->view) {ierr = (*wf->ops->view)(wf, v);CHKERRQ(ierr);}
15516528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
15526528b96dSMatthew G. Knepley }
15536528b96dSMatthew G. Knepley 
15546528b96dSMatthew G. Knepley /*@
15556528b96dSMatthew G. Knepley   PetscWeakFormCreate - Creates an empty PetscWeakForm object.
15566528b96dSMatthew G. Knepley 
15576528b96dSMatthew G. Knepley   Collective
15586528b96dSMatthew G. Knepley 
15596528b96dSMatthew G. Knepley   Input Parameter:
15606528b96dSMatthew G. Knepley . comm - The communicator for the PetscWeakForm object
15616528b96dSMatthew G. Knepley 
15626528b96dSMatthew G. Knepley   Output Parameter:
15636528b96dSMatthew G. Knepley . wf - The PetscWeakForm object
15646528b96dSMatthew G. Knepley 
15656528b96dSMatthew G. Knepley   Level: beginner
15666528b96dSMatthew G. Knepley 
15676528b96dSMatthew G. Knepley .seealso: PetscDS, PetscWeakFormDestroy()
15686528b96dSMatthew G. Knepley @*/
15696528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormCreate(MPI_Comm comm, PetscWeakForm *wf)
15706528b96dSMatthew G. Knepley {
15716528b96dSMatthew G. Knepley   PetscWeakForm  p;
15726528b96dSMatthew G. Knepley   PetscErrorCode ierr;
15736528b96dSMatthew G. Knepley 
15746528b96dSMatthew G. Knepley   PetscFunctionBegin;
15756528b96dSMatthew G. Knepley   PetscValidPointer(wf, 2);
15766528b96dSMatthew G. Knepley   *wf  = NULL;
15776528b96dSMatthew G. Knepley   ierr = PetscDSInitializePackage();CHKERRQ(ierr);
15786528b96dSMatthew G. Knepley 
15796528b96dSMatthew G. Knepley   ierr = PetscHeaderCreate(p, PETSCWEAKFORM_CLASSID, "PetscWeakForm", "Weak Form System", "PetscWeakForm", comm, PetscWeakFormDestroy, PetscWeakFormView);CHKERRQ(ierr);
15806528b96dSMatthew G. Knepley 
15816528b96dSMatthew G. Knepley   p->Nf = 0;
15826528b96dSMatthew G. Knepley   ierr = PetscChunkBufferCreate(sizeof(&PetscWeakFormCreate), 2, &p->funcs);CHKERRQ(ierr);
15836528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->obj);CHKERRQ(ierr);
15846528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->f0);CHKERRQ(ierr);
15856528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->f1);CHKERRQ(ierr);
15866528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->g0);CHKERRQ(ierr);
15876528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->g1);CHKERRQ(ierr);
15886528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->g2);CHKERRQ(ierr);
15896528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->g3);CHKERRQ(ierr);
15906528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->gp0);CHKERRQ(ierr);
15916528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->gp1);CHKERRQ(ierr);
15926528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->gp2);CHKERRQ(ierr);
15936528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->gp3);CHKERRQ(ierr);
15946528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->gt0);CHKERRQ(ierr);
15956528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->gt1);CHKERRQ(ierr);
15966528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->gt2);CHKERRQ(ierr);
15976528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->gt3);CHKERRQ(ierr);
15986528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->bdf0);CHKERRQ(ierr);
15996528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->bdf1);CHKERRQ(ierr);
16006528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->bdg0);CHKERRQ(ierr);
16016528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->bdg1);CHKERRQ(ierr);
16026528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->bdg2);CHKERRQ(ierr);
16036528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->bdg3);CHKERRQ(ierr);
16046528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->bdgp0);CHKERRQ(ierr);
16056528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->bdgp1);CHKERRQ(ierr);
16066528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->bdgp2);CHKERRQ(ierr);
16076528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->bdgp3);CHKERRQ(ierr);
16086528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->r);CHKERRQ(ierr);
16096528b96dSMatthew G. Knepley   *wf = p;
16106528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
16116528b96dSMatthew G. Knepley }
1612