xref: /petsc/src/dm/dt/interface/dtweakform.c (revision 2baeecee7a29e81349c9da7a98c5ac9cbcedeed5)
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 
186528b96dSMatthew G. Knepley static PetscErrorCode PetscChunkBufferDestroy(PetscChunkBuffer **buffer)
196528b96dSMatthew G. Knepley {
206528b96dSMatthew G. Knepley   PetscErrorCode ierr;
216528b96dSMatthew G. Knepley 
226528b96dSMatthew G. Knepley   PetscFunctionBegin;
236528b96dSMatthew G. Knepley   ierr = PetscFree((*buffer)->array);CHKERRQ(ierr);
246528b96dSMatthew G. Knepley   ierr = PetscFree(*buffer);CHKERRQ(ierr);
256528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
266528b96dSMatthew G. Knepley }
276528b96dSMatthew G. Knepley 
286528b96dSMatthew G. Knepley static PetscErrorCode PetscChunkBufferCreateChunk(PetscChunkBuffer *buffer, PetscInt size, PetscChunk *chunk)
296528b96dSMatthew G. Knepley {
306528b96dSMatthew G. Knepley   PetscErrorCode ierr;
316528b96dSMatthew G. Knepley 
326528b96dSMatthew G. Knepley   PetscFunctionBegin;
336528b96dSMatthew G. Knepley   if ((buffer->size + size)*buffer->unitbytes > buffer->alloc) {
346528b96dSMatthew G. Knepley     char *tmp;
356528b96dSMatthew G. Knepley 
366528b96dSMatthew G. Knepley     if (!buffer->alloc) buffer->alloc = (buffer->size + size)*buffer->unitbytes;
376528b96dSMatthew G. Knepley     while ((buffer->size + size)*buffer->unitbytes > buffer->alloc) buffer->alloc *= 2;
386528b96dSMatthew G. Knepley     ierr = PetscMalloc(buffer->alloc, &tmp);CHKERRQ(ierr);
396528b96dSMatthew G. Knepley     ierr = PetscMemcpy(tmp, buffer->array, buffer->size*buffer->unitbytes);CHKERRQ(ierr);
406528b96dSMatthew G. Knepley     ierr = PetscFree(buffer->array);CHKERRQ(ierr);
416528b96dSMatthew G. Knepley     buffer->array = tmp;
426528b96dSMatthew G. Knepley   }
43*2baeeceeSMatthew G. Knepley   chunk->start    = buffer->size*buffer->unitbytes;
446528b96dSMatthew G. Knepley   chunk->size     = size;
456528b96dSMatthew G. Knepley   chunk->reserved = size;
466528b96dSMatthew G. Knepley   buffer->size   += size;
476528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
486528b96dSMatthew G. Knepley }
496528b96dSMatthew G. Knepley 
506528b96dSMatthew G. Knepley static PetscErrorCode PetscChunkBufferEnlargeChunk(PetscChunkBuffer *buffer, PetscInt size, PetscChunk *chunk)
516528b96dSMatthew G. Knepley {
526528b96dSMatthew G. Knepley   size_t         siz = size;
536528b96dSMatthew G. Knepley   PetscErrorCode ierr;
546528b96dSMatthew G. Knepley 
556528b96dSMatthew G. Knepley   PetscFunctionBegin;
566528b96dSMatthew G. Knepley   if (chunk->size + size > chunk->reserved) {
576528b96dSMatthew G. Knepley     PetscChunk newchunk;
586528b96dSMatthew G. Knepley     PetscInt   reserved = chunk->size;
596528b96dSMatthew G. Knepley 
606528b96dSMatthew G. Knepley     /* TODO Here if we had a chunk list, we could update them all to reclaim unused space */
616528b96dSMatthew G. Knepley     while (reserved < chunk->size+size) reserved *= 2;
626528b96dSMatthew G. Knepley     ierr = PetscChunkBufferCreateChunk(buffer, (size_t) reserved, &newchunk);CHKERRQ(ierr);
636528b96dSMatthew G. Knepley     newchunk.size = chunk->size+size;
646528b96dSMatthew G. Knepley     ierr = PetscMemcpy(&buffer->array[newchunk.start], &buffer->array[chunk->start], chunk->size * buffer->unitbytes);CHKERRQ(ierr);
656528b96dSMatthew G. Knepley     *chunk = newchunk;
666528b96dSMatthew G. Knepley   } else {
676528b96dSMatthew G. Knepley     chunk->size += siz;
686528b96dSMatthew G. Knepley   }
696528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
706528b96dSMatthew G. Knepley }
716528b96dSMatthew G. Knepley 
726528b96dSMatthew G. Knepley /*@C
736528b96dSMatthew G. Knepley   PetscHashFormKeySort - Sorts an array of PetscHashFormKey in place in increasing order.
746528b96dSMatthew G. Knepley 
756528b96dSMatthew G. Knepley   Not Collective
766528b96dSMatthew G. Knepley 
776528b96dSMatthew G. Knepley   Input Parameters:
786528b96dSMatthew G. Knepley + n - number of values
796528b96dSMatthew G. Knepley - X - array of PetscHashFormKey
806528b96dSMatthew G. Knepley 
816528b96dSMatthew G. Knepley   Level: intermediate
826528b96dSMatthew G. Knepley 
836528b96dSMatthew G. Knepley .seealso: PetscIntSortSemiOrdered(), PetscSortInt()
846528b96dSMatthew G. Knepley @*/
856528b96dSMatthew G. Knepley PetscErrorCode PetscHashFormKeySort(PetscInt n, PetscHashFormKey arr[])
866528b96dSMatthew G. Knepley {
876528b96dSMatthew G. Knepley   PetscErrorCode ierr;
886528b96dSMatthew G. Knepley 
896528b96dSMatthew G. Knepley   PetscFunctionBegin;
906528b96dSMatthew G. Knepley   if (n <= 1) PetscFunctionReturn(0);
916528b96dSMatthew G. Knepley   PetscValidPointer(arr, 2);
926528b96dSMatthew G. Knepley   ierr = PetscTimSort(n, arr, sizeof(PetscHashFormKey), Compare_PetscHashFormKey_Private, NULL);CHKERRQ(ierr);
936528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
946528b96dSMatthew G. Knepley }
956528b96dSMatthew G. Knepley 
966528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormGetFunction_Private(PetscWeakForm wf, PetscHMapForm ht, DMLabel label, PetscInt value, PetscInt f, PetscInt *n, void (***func)())
976528b96dSMatthew G. Knepley {
986528b96dSMatthew G. Knepley   PetscHashFormKey key;
996528b96dSMatthew G. Knepley   PetscChunk       chunk;
1006528b96dSMatthew G. Knepley   PetscErrorCode   ierr;
1016528b96dSMatthew G. Knepley 
1026528b96dSMatthew G. Knepley   PetscFunctionBegin;
1036528b96dSMatthew G. Knepley   key.label = label; key.value = value; key.field = f;
1046528b96dSMatthew G. Knepley   ierr = PetscHMapFormGet(ht, key, &chunk);CHKERRQ(ierr);
1056528b96dSMatthew G. Knepley   if (chunk.size < 0) {*n = 0;          *func = NULL;}
106*2baeeceeSMatthew G. Knepley   else                {*n = chunk.size; *func = (void (**)()) &wf->funcs->array[chunk.start];}
1076528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
1086528b96dSMatthew G. Knepley }
1096528b96dSMatthew G. Knepley 
1106528b96dSMatthew G. Knepley /* A NULL argument for func causes this to clear the key */
1116528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetFunction_Private(PetscWeakForm wf, PetscHMapForm ht, DMLabel label, PetscInt value, PetscInt f, PetscInt n, void (**func)())
1126528b96dSMatthew G. Knepley {
1136528b96dSMatthew G. Knepley   PetscHashFormKey key;
1146528b96dSMatthew G. Knepley   PetscChunk       chunk;
1156528b96dSMatthew G. Knepley   PetscInt         i;
1166528b96dSMatthew G. Knepley   PetscErrorCode   ierr;
1176528b96dSMatthew G. Knepley 
1186528b96dSMatthew G. Knepley   PetscFunctionBegin;
1196528b96dSMatthew G. Knepley   key.label = label; key.value = value; key.field = f;
1206528b96dSMatthew G. Knepley   if (!func) {
1216528b96dSMatthew G. Knepley     ierr = PetscHMapFormDel(ht, key);CHKERRQ(ierr);
1226528b96dSMatthew G. Knepley     PetscFunctionReturn(0);
1236528b96dSMatthew G. Knepley   } else {
1246528b96dSMatthew G. Knepley     ierr = PetscHMapFormGet(ht, key, &chunk);CHKERRQ(ierr);
1256528b96dSMatthew G. Knepley   }
1266528b96dSMatthew G. Knepley   if (chunk.size < 0) {
1276528b96dSMatthew G. Knepley     ierr = PetscChunkBufferCreateChunk(wf->funcs, n, &chunk);CHKERRQ(ierr);
1286528b96dSMatthew G. Knepley     ierr = PetscHMapFormSet(ht, key, chunk);CHKERRQ(ierr);
1296528b96dSMatthew G. Knepley   } else if (chunk.size <= n) {
1306528b96dSMatthew G. Knepley     ierr = PetscChunkBufferEnlargeChunk(wf->funcs, n - chunk.size, &chunk);CHKERRQ(ierr);
1316528b96dSMatthew G. Knepley     ierr = PetscHMapFormSet(ht, key, chunk);CHKERRQ(ierr);
1326528b96dSMatthew G. Knepley   }
133*2baeeceeSMatthew G. Knepley   for (i = 0; i < n; ++i) ((void (**)()) &wf->funcs->array[chunk.start])[i] = func[i];
1346528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
1356528b96dSMatthew G. Knepley }
1366528b96dSMatthew G. Knepley 
1376528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormAddFunction_Private(PetscWeakForm wf, PetscHMapForm ht, DMLabel label, PetscInt value, PetscInt f, void (*func)())
1386528b96dSMatthew G. Knepley {
1396528b96dSMatthew G. Knepley   PetscHashFormKey key;
1406528b96dSMatthew G. Knepley   PetscChunk       chunk;
1416528b96dSMatthew G. Knepley   PetscErrorCode   ierr;
1426528b96dSMatthew G. Knepley 
1436528b96dSMatthew G. Knepley   PetscFunctionBegin;
1446528b96dSMatthew G. Knepley   if (!func) PetscFunctionReturn(0);
1456528b96dSMatthew G. Knepley   key.label = label; key.value = value; key.field = f;
1466528b96dSMatthew G. Knepley   ierr = PetscHMapFormGet(ht, key, &chunk);CHKERRQ(ierr);
1476528b96dSMatthew G. Knepley   if (chunk.size < 0) {
1486528b96dSMatthew G. Knepley     ierr = PetscChunkBufferCreateChunk(wf->funcs, 1, &chunk);CHKERRQ(ierr);
1496528b96dSMatthew G. Knepley     ierr = PetscHMapFormSet(ht, key, chunk);CHKERRQ(ierr);
150*2baeeceeSMatthew G. Knepley     ((void (**)()) &wf->funcs->array[chunk.start])[0] = func;
1516528b96dSMatthew G. Knepley   } else {
1526528b96dSMatthew G. Knepley     ierr = PetscChunkBufferEnlargeChunk(wf->funcs, 1, &chunk);CHKERRQ(ierr);
1536528b96dSMatthew G. Knepley     ierr = PetscHMapFormSet(ht, key, chunk);CHKERRQ(ierr);
154*2baeeceeSMatthew G. Knepley     ((void (**)()) &wf->funcs->array[chunk.start])[chunk.size-1] = func;
1556528b96dSMatthew G. Knepley   }
1566528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
1576528b96dSMatthew G. Knepley }
1586528b96dSMatthew G. Knepley 
1596528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormGetIndexFunction_Private(PetscWeakForm wf, PetscHMapForm ht, DMLabel label, PetscInt value, PetscInt f, PetscInt ind, void (**func)())
1606528b96dSMatthew G. Knepley {
1616528b96dSMatthew G. Knepley   PetscHashFormKey key;
1626528b96dSMatthew G. Knepley   PetscChunk       chunk;
1636528b96dSMatthew G. Knepley   PetscErrorCode   ierr;
1646528b96dSMatthew G. Knepley 
1656528b96dSMatthew G. Knepley   PetscFunctionBegin;
1666528b96dSMatthew G. Knepley   key.label = label; key.value = value; key.field = f;
1676528b96dSMatthew G. Knepley   ierr = PetscHMapFormGet(ht, key, &chunk);CHKERRQ(ierr);
1686528b96dSMatthew G. Knepley   if (chunk.size < 0) {*func = NULL;}
1696528b96dSMatthew G. Knepley   else {
1706528b96dSMatthew G. Knepley     if (ind >= chunk.size) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Index %D not in [0, %D)", ind, chunk.size);
171*2baeeceeSMatthew G. Knepley     *func = ((void (**)()) &wf->funcs->array[chunk.start])[ind];
1726528b96dSMatthew G. Knepley   }
1736528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
1746528b96dSMatthew G. Knepley }
1756528b96dSMatthew G. Knepley 
1766528b96dSMatthew G. Knepley /* A NULL argument for func causes this to clear the slot, and if there is nothing else, clear the key */
1776528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetIndexFunction_Private(PetscWeakForm wf, PetscHMapForm ht, DMLabel label, PetscInt value, PetscInt f, PetscInt ind, void (*func)())
1786528b96dSMatthew G. Knepley {
1796528b96dSMatthew G. Knepley   PetscHashFormKey key;
1806528b96dSMatthew G. Knepley   PetscChunk       chunk;
1816528b96dSMatthew G. Knepley   PetscErrorCode   ierr;
1826528b96dSMatthew G. Knepley 
1836528b96dSMatthew G. Knepley   PetscFunctionBegin;
1846528b96dSMatthew G. Knepley   key.label = label; key.value = value; key.field = f;
1856528b96dSMatthew G. Knepley   ierr = PetscHMapFormGet(ht, key, &chunk);CHKERRQ(ierr);
1866528b96dSMatthew G. Knepley   if (chunk.size < 0) {
1876528b96dSMatthew G. Knepley     if (!func) PetscFunctionReturn(0);
1886528b96dSMatthew G. Knepley     ierr = PetscChunkBufferCreateChunk(wf->funcs, ind+1, &chunk);CHKERRQ(ierr);
1896528b96dSMatthew G. Knepley     ierr = PetscHMapFormSet(ht, key, chunk);CHKERRQ(ierr);
1906528b96dSMatthew G. Knepley   } else if (!func && !ind && chunk.size == 1) {
1916528b96dSMatthew G. Knepley     ierr = PetscHMapFormDel(ht, key);CHKERRQ(ierr);
1926528b96dSMatthew G. Knepley     PetscFunctionReturn(0);
1936528b96dSMatthew G. Knepley   } else if (chunk.size <= ind) {
1946528b96dSMatthew G. Knepley     ierr = PetscChunkBufferEnlargeChunk(wf->funcs, ind - chunk.size + 1, &chunk);CHKERRQ(ierr);
1956528b96dSMatthew G. Knepley     ierr = PetscHMapFormSet(ht, key, chunk);CHKERRQ(ierr);
1966528b96dSMatthew G. Knepley   }
197*2baeeceeSMatthew G. Knepley   ((void (**)()) &wf->funcs->array[chunk.start])[ind] = func;
1986528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
1996528b96dSMatthew G. Knepley }
2006528b96dSMatthew G. Knepley 
2016528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormGetObjective(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt *n,
2026528b96dSMatthew G. Knepley                                          void (***obj)(PetscInt, PetscInt, PetscInt,
2036528b96dSMatthew G. Knepley                                                        const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
2046528b96dSMatthew G. Knepley                                                        const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
2056528b96dSMatthew G. Knepley                                                        PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
2066528b96dSMatthew G. Knepley {
2076528b96dSMatthew G. Knepley   PetscErrorCode ierr;
2086528b96dSMatthew G. Knepley 
2096528b96dSMatthew G. Knepley   PetscFunctionBegin;
2106528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->obj, label, val, f, n, (void (***)(void)) obj);CHKERRQ(ierr);
2116528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
2126528b96dSMatthew G. Knepley }
2136528b96dSMatthew G. Knepley 
2146528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetObjective(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt n,
2156528b96dSMatthew G. Knepley                                          void (**obj)(PetscInt, PetscInt, PetscInt,
2166528b96dSMatthew G. Knepley                                                       const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const  PetscScalar[],
2176528b96dSMatthew G. Knepley                                                       const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
2186528b96dSMatthew G. Knepley                                                       PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
2196528b96dSMatthew G. Knepley {
2206528b96dSMatthew G. Knepley   PetscErrorCode ierr;
2216528b96dSMatthew G. Knepley 
2226528b96dSMatthew G. Knepley   PetscFunctionBegin;
2236528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->obj, label, val, f, n, (void (**)(void)) obj);CHKERRQ(ierr);
2246528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
2256528b96dSMatthew G. Knepley }
2266528b96dSMatthew G. Knepley 
2276528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormAddObjective(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f,
2286528b96dSMatthew G. Knepley                                          void (*obj)(PetscInt, PetscInt, PetscInt,
2296528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
2306528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
2316528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
2326528b96dSMatthew G. Knepley {
2336528b96dSMatthew G. Knepley   PetscErrorCode ierr;
2346528b96dSMatthew G. Knepley 
2356528b96dSMatthew G. Knepley   PetscFunctionBegin;
2366528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->obj, label, val, f, (void (*)(void)) obj);CHKERRQ(ierr);
2376528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
2386528b96dSMatthew G. Knepley }
2396528b96dSMatthew G. Knepley 
2406528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormGetIndexObjective(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt ind,
2416528b96dSMatthew G. Knepley                                               void (**obj)(PetscInt, PetscInt, PetscInt,
2426528b96dSMatthew G. Knepley                                                            const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
2436528b96dSMatthew G. Knepley                                                            const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
2446528b96dSMatthew G. Knepley                                                            PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
2456528b96dSMatthew G. Knepley {
2466528b96dSMatthew G. Knepley   PetscErrorCode ierr;
2476528b96dSMatthew G. Knepley 
2486528b96dSMatthew G. Knepley   PetscFunctionBegin;
2496528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetIndexFunction_Private(wf, wf->obj, label, val, f, ind, (void (**)(void)) obj);CHKERRQ(ierr);
2506528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
2516528b96dSMatthew G. Knepley }
2526528b96dSMatthew G. Knepley 
2536528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetIndexObjective(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt ind,
2546528b96dSMatthew G. Knepley                                               void (*obj)(PetscInt, PetscInt, PetscInt,
2556528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
2566528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
2576528b96dSMatthew G. Knepley                                                           PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
2586528b96dSMatthew G. Knepley {
2596528b96dSMatthew G. Knepley   PetscErrorCode ierr;
2606528b96dSMatthew G. Knepley 
2616528b96dSMatthew G. Knepley   PetscFunctionBegin;
2626528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->obj, label, val, f, ind, (void (*)(void)) obj);CHKERRQ(ierr);
2636528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
2646528b96dSMatthew G. Knepley }
2656528b96dSMatthew G. Knepley 
2666528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormGetResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f,
2676528b96dSMatthew G. Knepley                                         PetscInt *n0,
2686528b96dSMatthew G. Knepley                                         void (***f0)(PetscInt, PetscInt, PetscInt,
2696528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
2706528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
2716528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
2726528b96dSMatthew G. Knepley                                         PetscInt *n1,
2736528b96dSMatthew G. Knepley                                         void (***f1)(PetscInt, PetscInt, PetscInt,
2746528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
2756528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
2766528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
2776528b96dSMatthew G. Knepley {
2786528b96dSMatthew G. Knepley   PetscErrorCode ierr;
2796528b96dSMatthew G. Knepley 
2806528b96dSMatthew G. Knepley   PetscFunctionBegin;
2816528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->f0, label, val, f, n0, (void (***)(void)) f0);CHKERRQ(ierr);
2826528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->f1, label, val, f, n1, (void (***)(void)) f1);CHKERRQ(ierr);
2836528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
2846528b96dSMatthew G. Knepley }
2856528b96dSMatthew G. Knepley 
2866528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormAddResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f,
2876528b96dSMatthew G. Knepley                                         void (*f0)(PetscInt, PetscInt, PetscInt,
2886528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
2896528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
2906528b96dSMatthew G. Knepley                                                    PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
2916528b96dSMatthew G. Knepley                                         void (*f1)(PetscInt, PetscInt, PetscInt,
2926528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
2936528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
2946528b96dSMatthew G. Knepley                                                    PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
2956528b96dSMatthew G. Knepley {
2966528b96dSMatthew G. Knepley   PetscErrorCode ierr;
2976528b96dSMatthew G. Knepley 
2986528b96dSMatthew G. Knepley   PetscFunctionBegin;
2996528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->f0, label, val, f, (void (*)(void)) f0);CHKERRQ(ierr);
3006528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->f1, label, val, f, (void (*)(void)) f1);CHKERRQ(ierr);
3016528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
3026528b96dSMatthew G. Knepley }
3036528b96dSMatthew G. Knepley 
3046528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f,
3056528b96dSMatthew G. Knepley                                         PetscInt n0,
3066528b96dSMatthew G. Knepley                                         void (**f0)(PetscInt, PetscInt, PetscInt,
3076528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
3086528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
3096528b96dSMatthew G. Knepley                                                    PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
3106528b96dSMatthew G. Knepley                                         PetscInt n1,
3116528b96dSMatthew G. Knepley                                         void (**f1)(PetscInt, PetscInt, PetscInt,
3126528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
3136528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
3146528b96dSMatthew G. Knepley                                                    PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
3156528b96dSMatthew G. Knepley {
3166528b96dSMatthew G. Knepley   PetscErrorCode ierr;
3176528b96dSMatthew G. Knepley 
3186528b96dSMatthew G. Knepley   PetscFunctionBegin;
3196528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->f0, label, val, f, n0, (void (**)(void)) f0);CHKERRQ(ierr);
3206528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->f1, label, val, f, n1, (void (**)(void)) f1);CHKERRQ(ierr);
3216528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
3226528b96dSMatthew G. Knepley }
3236528b96dSMatthew G. Knepley 
3246528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetIndexResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f,
3256528b96dSMatthew G. Knepley                                         PetscInt i0,
3266528b96dSMatthew G. Knepley                                         void (*f0)(PetscInt, PetscInt, PetscInt,
3276528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
3286528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
3296528b96dSMatthew G. Knepley                                                    PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
3306528b96dSMatthew G. Knepley                                         PetscInt i1,
3316528b96dSMatthew G. Knepley                                         void (*f1)(PetscInt, PetscInt, PetscInt,
3326528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
3336528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
3346528b96dSMatthew G. Knepley                                                    PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
3356528b96dSMatthew G. Knepley {
3366528b96dSMatthew G. Knepley   PetscErrorCode ierr;
3376528b96dSMatthew G. Knepley 
3386528b96dSMatthew G. Knepley   PetscFunctionBegin;
3396528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->f0, label, val, f, i0, (void (*)(void)) f0);CHKERRQ(ierr);
3406528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->f1, label, val, f, i1, (void (*)(void)) f1);CHKERRQ(ierr);
3416528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
3426528b96dSMatthew G. Knepley }
3436528b96dSMatthew G. Knepley 
3446528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormGetBdResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f,
3456528b96dSMatthew G. Knepley                                           PetscInt *n0,
3466528b96dSMatthew G. Knepley                                         void (***f0)(PetscInt, PetscInt, PetscInt,
3476528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
3486528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
3496528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
3506528b96dSMatthew G. Knepley                                         PetscInt *n1,
3516528b96dSMatthew G. Knepley                                         void (***f1)(PetscInt, PetscInt, PetscInt,
3526528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
3536528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
3546528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
3556528b96dSMatthew G. Knepley {
3566528b96dSMatthew G. Knepley   PetscErrorCode ierr;
3576528b96dSMatthew G. Knepley 
3586528b96dSMatthew G. Knepley   PetscFunctionBegin;
3596528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->bdf0, label, val, f, n0, (void (***)(void)) f0);CHKERRQ(ierr);
3606528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->bdf1, label, val, f, n1, (void (***)(void)) f1);CHKERRQ(ierr);
3616528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
3626528b96dSMatthew G. Knepley }
3636528b96dSMatthew G. Knepley 
3646528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormAddBdResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f,
3656528b96dSMatthew G. Knepley                                           void (*f0)(PetscInt, PetscInt, PetscInt,
3666528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
3676528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
3686528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
3696528b96dSMatthew G. Knepley                                           void (*f1)(PetscInt, PetscInt, PetscInt,
3706528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
3716528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
3726528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
3736528b96dSMatthew G. Knepley {
3746528b96dSMatthew G. Knepley   PetscErrorCode ierr;
3756528b96dSMatthew G. Knepley 
3766528b96dSMatthew G. Knepley   PetscFunctionBegin;
3776528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->bdf0, label, val, f, (void (*)(void)) f0);CHKERRQ(ierr);
3786528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->bdf1, label, val, f, (void (*)(void)) f1);CHKERRQ(ierr);
3796528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
3806528b96dSMatthew G. Knepley }
3816528b96dSMatthew G. Knepley 
3826528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetBdResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f,
3836528b96dSMatthew G. Knepley                                           PetscInt n0,
3846528b96dSMatthew G. Knepley                                           void (**f0)(PetscInt, PetscInt, PetscInt,
3856528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
3866528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
3876528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
3886528b96dSMatthew G. Knepley                                           PetscInt n1,
3896528b96dSMatthew G. Knepley                                           void (**f1)(PetscInt, PetscInt, PetscInt,
3906528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
3916528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
3926528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
3936528b96dSMatthew G. Knepley {
3946528b96dSMatthew G. Knepley   PetscErrorCode ierr;
3956528b96dSMatthew G. Knepley 
3966528b96dSMatthew G. Knepley   PetscFunctionBegin;
3976528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->bdf0, label, val, f, n0, (void (**)(void)) f0);CHKERRQ(ierr);
3986528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->bdf1, label, val, f, n1, (void (**)(void)) f1);CHKERRQ(ierr);
3996528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
4006528b96dSMatthew G. Knepley }
4016528b96dSMatthew G. Knepley 
4026528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetIndexBdResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f,
4036528b96dSMatthew G. Knepley                                           PetscInt i0,
4046528b96dSMatthew G. Knepley                                           void (*f0)(PetscInt, PetscInt, PetscInt,
4056528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4066528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4076528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
4086528b96dSMatthew G. Knepley                                           PetscInt i1,
4096528b96dSMatthew G. Knepley                                           void (*f1)(PetscInt, PetscInt, PetscInt,
4106528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4116528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4126528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
4136528b96dSMatthew G. Knepley {
4146528b96dSMatthew G. Knepley   PetscErrorCode ierr;
4156528b96dSMatthew G. Knepley 
4166528b96dSMatthew G. Knepley   PetscFunctionBegin;
4176528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->bdf0, label, val, f, i0, (void (*)(void)) f0);CHKERRQ(ierr);
4186528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->bdf1, label, val, f, i1, (void (*)(void)) f1);CHKERRQ(ierr);
4196528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
4206528b96dSMatthew G. Knepley }
4216528b96dSMatthew G. Knepley 
4226528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormHasJacobian(PetscWeakForm wf, PetscBool *hasJac)
4236528b96dSMatthew G. Knepley {
4246528b96dSMatthew G. Knepley   PetscInt       n0, n1, n2, n3;
4256528b96dSMatthew G. Knepley   PetscErrorCode ierr;
4266528b96dSMatthew G. Knepley 
4276528b96dSMatthew G. Knepley   PetscFunctionBegin;
4286528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
4296528b96dSMatthew G. Knepley   PetscValidBoolPointer(hasJac, 2);
4306528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->g0, &n0);CHKERRQ(ierr);
4316528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->g1, &n1);CHKERRQ(ierr);
4326528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->g2, &n2);CHKERRQ(ierr);
4336528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->g3, &n3);CHKERRQ(ierr);
4346528b96dSMatthew G. Knepley   *hasJac = n0+n1+n2+n3 ? PETSC_TRUE : PETSC_FALSE;
4356528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
4366528b96dSMatthew G. Knepley }
4376528b96dSMatthew G. Knepley 
4386528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormGetJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
4396528b96dSMatthew G. Knepley                                         PetscInt *n0,
4406528b96dSMatthew G. Knepley                                         void (***g0)(PetscInt, PetscInt, PetscInt,
4416528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4426528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4436528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
4446528b96dSMatthew G. Knepley                                         PetscInt *n1,
4456528b96dSMatthew G. Knepley                                         void (***g1)(PetscInt, PetscInt, PetscInt,
4466528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4476528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4486528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
4496528b96dSMatthew G. Knepley                                         PetscInt *n2,
4506528b96dSMatthew G. Knepley                                         void (***g2)(PetscInt, PetscInt, PetscInt,
4516528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4526528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4536528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
4546528b96dSMatthew G. Knepley                                         PetscInt *n3,
4556528b96dSMatthew G. Knepley                                         void (***g3)(PetscInt, PetscInt, PetscInt,
4566528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4576528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4586528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
4596528b96dSMatthew G. Knepley {
4606528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
4616528b96dSMatthew G. Knepley   PetscErrorCode ierr;
4626528b96dSMatthew G. Knepley 
4636528b96dSMatthew G. Knepley   PetscFunctionBegin;
4646528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->g0, label, val, find, n0, (void (***)(void)) g0);CHKERRQ(ierr);
4656528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->g1, label, val, find, n1, (void (***)(void)) g1);CHKERRQ(ierr);
4666528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->g2, label, val, find, n2, (void (***)(void)) g2);CHKERRQ(ierr);
4676528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->g3, label, val, find, n3, (void (***)(void)) g3);CHKERRQ(ierr);
4686528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
4696528b96dSMatthew G. Knepley }
4706528b96dSMatthew G. Knepley 
4716528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormAddJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
4726528b96dSMatthew G. Knepley                                         void (*g0)(PetscInt, PetscInt, PetscInt,
4736528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4746528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4756528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
4766528b96dSMatthew G. Knepley                                         void (*g1)(PetscInt, PetscInt, PetscInt,
4776528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4786528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4796528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
4806528b96dSMatthew G. Knepley                                         void (*g2)(PetscInt, PetscInt, PetscInt,
4816528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4826528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4836528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
4846528b96dSMatthew G. Knepley                                         void (*g3)(PetscInt, PetscInt, PetscInt,
4856528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4866528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4876528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
4886528b96dSMatthew G. Knepley {
4896528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
4906528b96dSMatthew G. Knepley   PetscErrorCode ierr;
4916528b96dSMatthew G. Knepley 
4926528b96dSMatthew G. Knepley   PetscFunctionBegin;
4936528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->g0, label, val, find, (void (*)(void)) g0);CHKERRQ(ierr);
4946528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->g1, label, val, find, (void (*)(void)) g1);CHKERRQ(ierr);
4956528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->g2, label, val, find, (void (*)(void)) g2);CHKERRQ(ierr);
4966528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->g3, label, val, find, (void (*)(void)) g3);CHKERRQ(ierr);
4976528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
4986528b96dSMatthew G. Knepley }
4996528b96dSMatthew G. Knepley 
5006528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
5016528b96dSMatthew G. Knepley                                         PetscInt n0,
5026528b96dSMatthew G. Knepley                                         void (**g0)(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, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
5066528b96dSMatthew G. Knepley                                         PetscInt n1,
5076528b96dSMatthew G. Knepley                                         void (**g1)(PetscInt, PetscInt, PetscInt,
5086528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5096528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5106528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
5116528b96dSMatthew G. Knepley                                         PetscInt n2,
5126528b96dSMatthew G. Knepley                                         void (**g2)(PetscInt, PetscInt, PetscInt,
5136528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5146528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5156528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
5166528b96dSMatthew G. Knepley                                         PetscInt n3,
5176528b96dSMatthew G. Knepley                                         void (**g3)(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, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
5216528b96dSMatthew G. Knepley {
5226528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
5236528b96dSMatthew G. Knepley   PetscErrorCode ierr;
5246528b96dSMatthew G. Knepley 
5256528b96dSMatthew G. Knepley   PetscFunctionBegin;
5266528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->g0, label, val, find, n0, (void (**)(void)) g0);CHKERRQ(ierr);
5276528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->g1, label, val, find, n1, (void (**)(void)) g1);CHKERRQ(ierr);
5286528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->g2, label, val, find, n2, (void (**)(void)) g2);CHKERRQ(ierr);
5296528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->g3, label, val, find, n3, (void (**)(void)) g3);CHKERRQ(ierr);
5306528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
5316528b96dSMatthew G. Knepley }
5326528b96dSMatthew G. Knepley 
5336528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetIndexJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
5346528b96dSMatthew G. Knepley                                         PetscInt i0,
5356528b96dSMatthew G. Knepley                                         void (*g0)(PetscInt, PetscInt, PetscInt,
5366528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5376528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5386528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
5396528b96dSMatthew G. Knepley                                         PetscInt i1,
5406528b96dSMatthew G. Knepley                                         void (*g1)(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, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
5446528b96dSMatthew G. Knepley                                         PetscInt i2,
5456528b96dSMatthew G. Knepley                                         void (*g2)(PetscInt, PetscInt, PetscInt,
5466528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5476528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5486528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
5496528b96dSMatthew G. Knepley                                         PetscInt i3,
5506528b96dSMatthew G. Knepley                                         void (*g3)(PetscInt, PetscInt, PetscInt,
5516528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5526528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5536528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
5546528b96dSMatthew G. Knepley {
5556528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
5566528b96dSMatthew G. Knepley   PetscErrorCode ierr;
5576528b96dSMatthew G. Knepley 
5586528b96dSMatthew G. Knepley   PetscFunctionBegin;
5596528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->g0, label, val, find, i0, (void (*)(void)) g0);CHKERRQ(ierr);
5606528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->g1, label, val, find, i1, (void (*)(void)) g1);CHKERRQ(ierr);
5616528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->g2, label, val, find, i2, (void (*)(void)) g2);CHKERRQ(ierr);
5626528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->g3, label, val, find, i3, (void (*)(void)) g3);CHKERRQ(ierr);
5636528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
5646528b96dSMatthew G. Knepley }
5656528b96dSMatthew G. Knepley 
5666528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormHasJacobianPreconditioner(PetscWeakForm wf, PetscBool *hasJacPre)
5676528b96dSMatthew G. Knepley {
5686528b96dSMatthew G. Knepley   PetscInt       n0, n1, n2, n3;
5696528b96dSMatthew G. Knepley   PetscErrorCode ierr;
5706528b96dSMatthew G. Knepley 
5716528b96dSMatthew G. Knepley   PetscFunctionBegin;
5726528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
5736528b96dSMatthew G. Knepley   PetscValidBoolPointer(hasJacPre, 2);
5746528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->gp0, &n0);CHKERRQ(ierr);
5756528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->gp1, &n1);CHKERRQ(ierr);
5766528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->gp2, &n2);CHKERRQ(ierr);
5776528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->gp3, &n3);CHKERRQ(ierr);
5786528b96dSMatthew G. Knepley   *hasJacPre = n0+n1+n2+n3 ? PETSC_TRUE : PETSC_FALSE;
5796528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
5806528b96dSMatthew G. Knepley }
5816528b96dSMatthew G. Knepley 
5826528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormGetJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
5836528b96dSMatthew G. Knepley                                                       PetscInt *n0,
5846528b96dSMatthew G. Knepley                                                       void (***g0)(PetscInt, PetscInt, PetscInt,
5856528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5866528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5876528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
5886528b96dSMatthew G. Knepley                                                       PetscInt *n1,
5896528b96dSMatthew G. Knepley                                                       void (***g1)(PetscInt, PetscInt, PetscInt,
5906528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5916528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5926528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
5936528b96dSMatthew G. Knepley                                                       PetscInt *n2,
5946528b96dSMatthew G. Knepley                                                       void (***g2)(PetscInt, PetscInt, PetscInt,
5956528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5966528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5976528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
5986528b96dSMatthew G. Knepley                                                       PetscInt *n3,
5996528b96dSMatthew G. Knepley                                                       void (***g3)(PetscInt, PetscInt, PetscInt,
6006528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6016528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6026528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
6036528b96dSMatthew G. Knepley {
6046528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
6056528b96dSMatthew G. Knepley   PetscErrorCode ierr;
6066528b96dSMatthew G. Knepley 
6076528b96dSMatthew G. Knepley   PetscFunctionBegin;
6086528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->gp0, label, val, find, n0, (void (***)(void)) g0);CHKERRQ(ierr);
6096528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->gp1, label, val, find, n1, (void (***)(void)) g1);CHKERRQ(ierr);
6106528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->gp2, label, val, find, n2, (void (***)(void)) g2);CHKERRQ(ierr);
6116528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->gp3, label, val, find, n3, (void (***)(void)) g3);CHKERRQ(ierr);
6126528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
6136528b96dSMatthew G. Knepley }
6146528b96dSMatthew G. Knepley 
6156528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormAddJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
6166528b96dSMatthew G. Knepley                                         void (*g0)(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                                         void (*g1)(PetscInt, PetscInt, PetscInt,
6216528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6226528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6236528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
6246528b96dSMatthew G. Knepley                                         void (*g2)(PetscInt, PetscInt, PetscInt,
6256528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6266528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6276528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
6286528b96dSMatthew G. Knepley                                         void (*g3)(PetscInt, PetscInt, PetscInt,
6296528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6306528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6316528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
6326528b96dSMatthew G. Knepley {
6336528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
6346528b96dSMatthew G. Knepley   PetscErrorCode ierr;
6356528b96dSMatthew G. Knepley 
6366528b96dSMatthew G. Knepley   PetscFunctionBegin;
6376528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->gp0, label, val, find, (void (*)(void)) g0);CHKERRQ(ierr);
6386528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->gp1, label, val, find, (void (*)(void)) g1);CHKERRQ(ierr);
6396528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->gp2, label, val, find, (void (*)(void)) g2);CHKERRQ(ierr);
6406528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->gp3, label, val, find, (void (*)(void)) g3);CHKERRQ(ierr);
6416528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
6426528b96dSMatthew G. Knepley }
6436528b96dSMatthew G. Knepley 
6446528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
6456528b96dSMatthew G. Knepley                                                       PetscInt n0,
6466528b96dSMatthew G. Knepley                                                       void (**g0)(PetscInt, PetscInt, PetscInt,
6476528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6486528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6496528b96dSMatthew G. Knepley                                                                  PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
6506528b96dSMatthew G. Knepley                                                       PetscInt n1,
6516528b96dSMatthew G. Knepley                                                       void (**g1)(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                                                       PetscInt n2,
6566528b96dSMatthew G. Knepley                                                       void (**g2)(PetscInt, PetscInt, PetscInt,
6576528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6586528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6596528b96dSMatthew G. Knepley                                                                  PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
6606528b96dSMatthew G. Knepley                                                       PetscInt n3,
6616528b96dSMatthew G. Knepley                                                       void (**g3)(PetscInt, PetscInt, PetscInt,
6626528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6636528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6646528b96dSMatthew G. Knepley                                                                  PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
6656528b96dSMatthew G. Knepley {
6666528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
6676528b96dSMatthew G. Knepley   PetscErrorCode ierr;
6686528b96dSMatthew G. Knepley 
6696528b96dSMatthew G. Knepley   PetscFunctionBegin;
6706528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->gp0, label, val, find, n0, (void (**)(void)) g0);CHKERRQ(ierr);
6716528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->gp1, label, val, find, n1, (void (**)(void)) g1);CHKERRQ(ierr);
6726528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->gp2, label, val, find, n2, (void (**)(void)) g2);CHKERRQ(ierr);
6736528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->gp3, label, val, find, n3, (void (**)(void)) g3);CHKERRQ(ierr);
6746528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
6756528b96dSMatthew G. Knepley }
6766528b96dSMatthew G. Knepley 
6776528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetIndexJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
6786528b96dSMatthew G. Knepley                                                       PetscInt i0,
6796528b96dSMatthew G. Knepley                                                       void (*g0)(PetscInt, PetscInt, PetscInt,
6806528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6816528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6826528b96dSMatthew G. Knepley                                                                  PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
6836528b96dSMatthew G. Knepley                                                       PetscInt i1,
6846528b96dSMatthew G. Knepley                                                       void (*g1)(PetscInt, PetscInt, PetscInt,
6856528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6866528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6876528b96dSMatthew G. Knepley                                                                  PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
6886528b96dSMatthew G. Knepley                                                       PetscInt i2,
6896528b96dSMatthew G. Knepley                                                       void (*g2)(PetscInt, PetscInt, PetscInt,
6906528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6916528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6926528b96dSMatthew G. Knepley                                                                  PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
6936528b96dSMatthew G. Knepley                                                       PetscInt i3,
6946528b96dSMatthew G. Knepley                                                       void (*g3)(PetscInt, PetscInt, PetscInt,
6956528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6966528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6976528b96dSMatthew G. Knepley                                                                  PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
6986528b96dSMatthew G. Knepley {
6996528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
7006528b96dSMatthew G. Knepley   PetscErrorCode ierr;
7016528b96dSMatthew G. Knepley 
7026528b96dSMatthew G. Knepley   PetscFunctionBegin;
7036528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->gp0, label, val, find, i0, (void (*)(void)) g0);CHKERRQ(ierr);
7046528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->gp1, label, val, find, i1, (void (*)(void)) g1);CHKERRQ(ierr);
7056528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->gp2, label, val, find, i2, (void (*)(void)) g2);CHKERRQ(ierr);
7066528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->gp3, label, val, find, i3, (void (*)(void)) g3);CHKERRQ(ierr);
7076528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
7086528b96dSMatthew G. Knepley }
7096528b96dSMatthew G. Knepley 
7106528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormHasBdJacobian(PetscWeakForm wf, PetscBool *hasJac)
7116528b96dSMatthew G. Knepley {
7126528b96dSMatthew G. Knepley   PetscInt       n0, n1, n2, n3;
7136528b96dSMatthew G. Knepley   PetscErrorCode ierr;
7146528b96dSMatthew G. Knepley 
7156528b96dSMatthew G. Knepley   PetscFunctionBegin;
7166528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
7176528b96dSMatthew G. Knepley   PetscValidBoolPointer(hasJac, 2);
7186528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->bdg0, &n0);CHKERRQ(ierr);
7196528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->bdg1, &n1);CHKERRQ(ierr);
7206528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->bdg2, &n2);CHKERRQ(ierr);
7216528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->bdg3, &n3);CHKERRQ(ierr);
7226528b96dSMatthew G. Knepley   *hasJac = n0+n1+n2+n3 ? PETSC_TRUE : PETSC_FALSE;
7236528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
7246528b96dSMatthew G. Knepley }
7256528b96dSMatthew G. Knepley 
7266528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormGetBdJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
7276528b96dSMatthew G. Knepley                                           PetscInt *n0,
7286528b96dSMatthew G. Knepley                                           void (***g0)(PetscInt, PetscInt, PetscInt,
7296528b96dSMatthew G. Knepley                                                        const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7306528b96dSMatthew G. Knepley                                                        const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7316528b96dSMatthew G. Knepley                                                        PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
7326528b96dSMatthew G. Knepley                                           PetscInt *n1,
7336528b96dSMatthew G. Knepley                                           void (***g1)(PetscInt, PetscInt, PetscInt,
7346528b96dSMatthew G. Knepley                                                        const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7356528b96dSMatthew G. Knepley                                                        const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7366528b96dSMatthew G. Knepley                                                        PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
7376528b96dSMatthew G. Knepley                                           PetscInt *n2,
7386528b96dSMatthew G. Knepley                                           void (***g2)(PetscInt, PetscInt, PetscInt,
7396528b96dSMatthew G. Knepley                                                        const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7406528b96dSMatthew G. Knepley                                                        const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7416528b96dSMatthew G. Knepley                                                        PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
7426528b96dSMatthew G. Knepley                                           PetscInt *n3,
7436528b96dSMatthew G. Knepley                                           void (***g3)(PetscInt, PetscInt, PetscInt,
7446528b96dSMatthew G. Knepley                                                        const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7456528b96dSMatthew G. Knepley                                                        const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7466528b96dSMatthew G. Knepley                                                        PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
7476528b96dSMatthew G. Knepley {
7486528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
7496528b96dSMatthew G. Knepley   PetscErrorCode ierr;
7506528b96dSMatthew G. Knepley 
7516528b96dSMatthew G. Knepley   PetscFunctionBegin;
7526528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->bdg0, label, val, find, n0, (void (***)(void)) g0);CHKERRQ(ierr);
7536528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->bdg1, label, val, find, n1, (void (***)(void)) g1);CHKERRQ(ierr);
7546528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->bdg2, label, val, find, n2, (void (***)(void)) g2);CHKERRQ(ierr);
7556528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->bdg3, label, val, find, n3, (void (***)(void)) g3);CHKERRQ(ierr);
7566528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
7576528b96dSMatthew G. Knepley }
7586528b96dSMatthew G. Knepley 
7596528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormAddBdJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
7606528b96dSMatthew G. Knepley                                           void (*g0)(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[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
7646528b96dSMatthew G. Knepley                                           void (*g1)(PetscInt, PetscInt, PetscInt,
7656528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7666528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7676528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
7686528b96dSMatthew G. Knepley                                           void (*g2)(PetscInt, PetscInt, PetscInt,
7696528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7706528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7716528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
7726528b96dSMatthew G. Knepley                                           void (*g3)(PetscInt, PetscInt, PetscInt,
7736528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7746528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7756528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
7766528b96dSMatthew G. Knepley {
7776528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
7786528b96dSMatthew G. Knepley   PetscErrorCode ierr;
7796528b96dSMatthew G. Knepley 
7806528b96dSMatthew G. Knepley   PetscFunctionBegin;
7816528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->bdg0, label, val, find, (void (*)(void)) g0);CHKERRQ(ierr);
7826528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->bdg1, label, val, find, (void (*)(void)) g1);CHKERRQ(ierr);
7836528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->bdg2, label, val, find, (void (*)(void)) g2);CHKERRQ(ierr);
7846528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->bdg3, label, val, find, (void (*)(void)) g3);CHKERRQ(ierr);
7856528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
7866528b96dSMatthew G. Knepley }
7876528b96dSMatthew G. Knepley 
7886528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetBdJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
7896528b96dSMatthew G. Knepley                                           PetscInt n0,
7906528b96dSMatthew G. Knepley                                           void (**g0)(PetscInt, PetscInt, PetscInt,
7916528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7926528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7936528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
7946528b96dSMatthew G. Knepley                                           PetscInt n1,
7956528b96dSMatthew G. Knepley                                           void (**g1)(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[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
7996528b96dSMatthew G. Knepley                                           PetscInt n2,
8006528b96dSMatthew G. Knepley                                           void (**g2)(PetscInt, PetscInt, PetscInt,
8016528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8026528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8036528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
8046528b96dSMatthew G. Knepley                                           PetscInt n3,
8056528b96dSMatthew G. Knepley                                           void (**g3)(PetscInt, PetscInt, PetscInt,
8066528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8076528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8086528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
8096528b96dSMatthew G. Knepley {
8106528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
8116528b96dSMatthew G. Knepley   PetscErrorCode ierr;
8126528b96dSMatthew G. Knepley 
8136528b96dSMatthew G. Knepley   PetscFunctionBegin;
8146528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->bdg0, label, val, find, n0, (void (**)(void)) g0);CHKERRQ(ierr);
8156528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->bdg1, label, val, find, n1, (void (**)(void)) g1);CHKERRQ(ierr);
8166528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->bdg2, label, val, find, n2, (void (**)(void)) g2);CHKERRQ(ierr);
8176528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->bdg3, label, val, find, n3, (void (**)(void)) g3);CHKERRQ(ierr);
8186528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
8196528b96dSMatthew G. Knepley }
8206528b96dSMatthew G. Knepley 
8216528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetIndexBdJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
8226528b96dSMatthew G. Knepley                                           PetscInt i0,
8236528b96dSMatthew G. Knepley                                           void (*g0)(PetscInt, PetscInt, PetscInt,
8246528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8256528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8266528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
8276528b96dSMatthew G. Knepley                                           PetscInt i1,
8286528b96dSMatthew G. Knepley                                           void (*g1)(PetscInt, PetscInt, PetscInt,
8296528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8306528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8316528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
8326528b96dSMatthew G. Knepley                                           PetscInt i2,
8336528b96dSMatthew G. Knepley                                           void (*g2)(PetscInt, PetscInt, PetscInt,
8346528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8356528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8366528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
8376528b96dSMatthew G. Knepley                                           PetscInt i3,
8386528b96dSMatthew G. Knepley                                           void (*g3)(PetscInt, PetscInt, PetscInt,
8396528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8406528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8416528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
8426528b96dSMatthew G. Knepley {
8436528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
8446528b96dSMatthew G. Knepley   PetscErrorCode ierr;
8456528b96dSMatthew G. Knepley 
8466528b96dSMatthew G. Knepley   PetscFunctionBegin;
8476528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->bdg0, label, val, find, i0, (void (*)(void)) g0);CHKERRQ(ierr);
8486528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->bdg1, label, val, find, i1, (void (*)(void)) g1);CHKERRQ(ierr);
8496528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->bdg2, label, val, find, i2, (void (*)(void)) g2);CHKERRQ(ierr);
8506528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->bdg3, label, val, find, i3, (void (*)(void)) g3);CHKERRQ(ierr);
8516528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
8526528b96dSMatthew G. Knepley }
8536528b96dSMatthew G. Knepley 
8546528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormHasBdJacobianPreconditioner(PetscWeakForm wf, PetscBool *hasJacPre)
8556528b96dSMatthew G. Knepley {
8566528b96dSMatthew G. Knepley   PetscInt       n0, n1, n2, n3;
8576528b96dSMatthew G. Knepley   PetscErrorCode ierr;
8586528b96dSMatthew G. Knepley 
8596528b96dSMatthew G. Knepley   PetscFunctionBegin;
8606528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
8616528b96dSMatthew G. Knepley   PetscValidBoolPointer(hasJacPre, 2);
8626528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->bdgp0, &n0);CHKERRQ(ierr);
8636528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->bdgp1, &n1);CHKERRQ(ierr);
8646528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->bdgp2, &n2);CHKERRQ(ierr);
8656528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->bdgp3, &n3);CHKERRQ(ierr);
8666528b96dSMatthew G. Knepley   *hasJacPre = n0+n1+n2+n3 ? PETSC_TRUE : PETSC_FALSE;
8676528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
8686528b96dSMatthew G. Knepley }
8696528b96dSMatthew G. Knepley 
8706528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormGetBdJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
8716528b96dSMatthew G. Knepley                                                         PetscInt *n0,
8726528b96dSMatthew G. Knepley                                                         void (***g0)(PetscInt, PetscInt, PetscInt,
8736528b96dSMatthew G. Knepley                                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8746528b96dSMatthew G. Knepley                                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8756528b96dSMatthew G. Knepley                                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
8766528b96dSMatthew G. Knepley                                                         PetscInt *n1,
8776528b96dSMatthew G. Knepley                                                         void (***g1)(PetscInt, PetscInt, PetscInt,
8786528b96dSMatthew G. Knepley                                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8796528b96dSMatthew G. Knepley                                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8806528b96dSMatthew G. Knepley                                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
8816528b96dSMatthew G. Knepley                                                         PetscInt *n2,
8826528b96dSMatthew G. Knepley                                                         void (***g2)(PetscInt, PetscInt, PetscInt,
8836528b96dSMatthew G. Knepley                                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8846528b96dSMatthew G. Knepley                                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8856528b96dSMatthew G. Knepley                                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
8866528b96dSMatthew G. Knepley                                                         PetscInt *n3,
8876528b96dSMatthew G. Knepley                                                         void (***g3)(PetscInt, PetscInt, PetscInt,
8886528b96dSMatthew G. Knepley                                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8896528b96dSMatthew G. Knepley                                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8906528b96dSMatthew G. Knepley                                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
8916528b96dSMatthew G. Knepley {
8926528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
8936528b96dSMatthew G. Knepley   PetscErrorCode ierr;
8946528b96dSMatthew G. Knepley 
8956528b96dSMatthew G. Knepley   PetscFunctionBegin;
8966528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->bdgp0, label, val, find, n0, (void (***)(void)) g0);CHKERRQ(ierr);
8976528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->bdgp1, label, val, find, n1, (void (***)(void)) g1);CHKERRQ(ierr);
8986528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->bdgp2, label, val, find, n2, (void (***)(void)) g2);CHKERRQ(ierr);
8996528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->bdgp3, label, val, find, n3, (void (***)(void)) g3);CHKERRQ(ierr);
9006528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
9016528b96dSMatthew G. Knepley }
9026528b96dSMatthew G. Knepley 
9036528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormAddBdJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
9046528b96dSMatthew G. Knepley                                                         void (*g0)(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                                                         void (*g1)(PetscInt, PetscInt, PetscInt,
9096528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9106528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9116528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
9126528b96dSMatthew G. Knepley                                                         void (*g2)(PetscInt, PetscInt, PetscInt,
9136528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9146528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9156528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
9166528b96dSMatthew G. Knepley                                                         void (*g3)(PetscInt, PetscInt, PetscInt,
9176528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9186528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9196528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
9206528b96dSMatthew G. Knepley {
9216528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
9226528b96dSMatthew G. Knepley   PetscErrorCode ierr;
9236528b96dSMatthew G. Knepley 
9246528b96dSMatthew G. Knepley   PetscFunctionBegin;
9256528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->bdgp0, label, val, find, (void (*)(void)) g0);CHKERRQ(ierr);
9266528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->bdgp1, label, val, find, (void (*)(void)) g1);CHKERRQ(ierr);
9276528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->bdgp2, label, val, find, (void (*)(void)) g2);CHKERRQ(ierr);
9286528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->bdgp3, label, val, find, (void (*)(void)) g3);CHKERRQ(ierr);
9296528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
9306528b96dSMatthew G. Knepley }
9316528b96dSMatthew G. Knepley 
9326528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetBdJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
9336528b96dSMatthew G. Knepley                                                         PetscInt n0,
9346528b96dSMatthew G. Knepley                                                         void (**g0)(PetscInt, PetscInt, PetscInt,
9356528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9366528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9376528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
9386528b96dSMatthew G. Knepley                                                         PetscInt n1,
9396528b96dSMatthew G. Knepley                                                         void (**g1)(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                                                         PetscInt n2,
9446528b96dSMatthew G. Knepley                                                         void (**g2)(PetscInt, PetscInt, PetscInt,
9456528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9466528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9476528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
9486528b96dSMatthew G. Knepley                                                         PetscInt n3,
9496528b96dSMatthew G. Knepley                                                         void (**g3)(PetscInt, PetscInt, PetscInt,
9506528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9516528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9526528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
9536528b96dSMatthew G. Knepley {
9546528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
9556528b96dSMatthew G. Knepley   PetscErrorCode ierr;
9566528b96dSMatthew G. Knepley 
9576528b96dSMatthew G. Knepley   PetscFunctionBegin;
9586528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->bdgp0, label, val, find, n0, (void (**)(void)) g0);CHKERRQ(ierr);
9596528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->bdgp1, label, val, find, n1, (void (**)(void)) g1);CHKERRQ(ierr);
9606528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->bdgp2, label, val, find, n2, (void (**)(void)) g2);CHKERRQ(ierr);
9616528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->bdgp3, label, val, find, n3, (void (**)(void)) g3);CHKERRQ(ierr);
9626528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
9636528b96dSMatthew G. Knepley }
9646528b96dSMatthew G. Knepley 
9656528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetIndexBdJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
9666528b96dSMatthew G. Knepley                                                         PetscInt i0,
9676528b96dSMatthew G. Knepley                                                         void (*g0)(PetscInt, PetscInt, PetscInt,
9686528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9696528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9706528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
9716528b96dSMatthew G. Knepley                                                         PetscInt i1,
9726528b96dSMatthew G. Knepley                                                         void (*g1)(PetscInt, PetscInt, PetscInt,
9736528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9746528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9756528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
9766528b96dSMatthew G. Knepley                                                         PetscInt i2,
9776528b96dSMatthew G. Knepley                                                         void (*g2)(PetscInt, PetscInt, PetscInt,
9786528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9796528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9806528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
9816528b96dSMatthew G. Knepley                                                         PetscInt i3,
9826528b96dSMatthew G. Knepley                                                         void (*g3)(PetscInt, PetscInt, PetscInt,
9836528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9846528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9856528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
9866528b96dSMatthew G. Knepley {
9876528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
9886528b96dSMatthew G. Knepley   PetscErrorCode ierr;
9896528b96dSMatthew G. Knepley 
9906528b96dSMatthew G. Knepley   PetscFunctionBegin;
9916528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->bdgp0, label, val, find, i0, (void (*)(void)) g0);CHKERRQ(ierr);
9926528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->bdgp1, label, val, find, i1, (void (*)(void)) g1);CHKERRQ(ierr);
9936528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->bdgp2, label, val, find, i2, (void (*)(void)) g2);CHKERRQ(ierr);
9946528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->bdgp3, label, val, find, i3, (void (*)(void)) g3);CHKERRQ(ierr);
9956528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
9966528b96dSMatthew G. Knepley }
9976528b96dSMatthew G. Knepley 
9986528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormHasDynamicJacobian(PetscWeakForm wf, PetscBool *hasDynJac)
9996528b96dSMatthew G. Knepley {
10006528b96dSMatthew G. Knepley   PetscInt       n0, n1, n2, n3;
10016528b96dSMatthew G. Knepley   PetscErrorCode ierr;
10026528b96dSMatthew G. Knepley 
10036528b96dSMatthew G. Knepley   PetscFunctionBegin;
10046528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
10056528b96dSMatthew G. Knepley   PetscValidBoolPointer(hasDynJac, 2);
10066528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->gt0, &n0);CHKERRQ(ierr);
10076528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->gt1, &n1);CHKERRQ(ierr);
10086528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->gt2, &n2);CHKERRQ(ierr);
10096528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->gt3, &n3);CHKERRQ(ierr);
10106528b96dSMatthew G. Knepley   *hasDynJac = n0+n1+n2+n3 ? PETSC_TRUE : PETSC_FALSE;
10116528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
10126528b96dSMatthew G. Knepley }
10136528b96dSMatthew G. Knepley 
10146528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormGetDynamicJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
10156528b96dSMatthew G. Knepley                                         PetscInt *n0,
10166528b96dSMatthew G. Knepley                                         void (***g0)(PetscInt, PetscInt, PetscInt,
10176528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10186528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10196528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
10206528b96dSMatthew G. Knepley                                         PetscInt *n1,
10216528b96dSMatthew G. Knepley                                         void (***g1)(PetscInt, PetscInt, PetscInt,
10226528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10236528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10246528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
10256528b96dSMatthew G. Knepley                                         PetscInt *n2,
10266528b96dSMatthew G. Knepley                                         void (***g2)(PetscInt, PetscInt, PetscInt,
10276528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10286528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10296528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
10306528b96dSMatthew G. Knepley                                         PetscInt *n3,
10316528b96dSMatthew G. Knepley                                         void (***g3)(PetscInt, PetscInt, PetscInt,
10326528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10336528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10346528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
10356528b96dSMatthew G. Knepley {
10366528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
10376528b96dSMatthew G. Knepley   PetscErrorCode ierr;
10386528b96dSMatthew G. Knepley 
10396528b96dSMatthew G. Knepley   PetscFunctionBegin;
10406528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->gt0, label, val, find, n0, (void (***)(void)) g0);CHKERRQ(ierr);
10416528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->gt1, label, val, find, n1, (void (***)(void)) g1);CHKERRQ(ierr);
10426528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->gt2, label, val, find, n2, (void (***)(void)) g2);CHKERRQ(ierr);
10436528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->gt3, label, val, find, n3, (void (***)(void)) g3);CHKERRQ(ierr);
10446528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
10456528b96dSMatthew G. Knepley }
10466528b96dSMatthew G. Knepley 
10476528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormAddDynamicJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
10486528b96dSMatthew G. Knepley                                         void (*g0)(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[], PetscInt, const PetscScalar[], PetscScalar[]),
10526528b96dSMatthew G. Knepley                                         void (*g1)(PetscInt, PetscInt, PetscInt,
10536528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10546528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10556528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
10566528b96dSMatthew G. Knepley                                         void (*g2)(PetscInt, PetscInt, PetscInt,
10576528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10586528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10596528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
10606528b96dSMatthew G. Knepley                                         void (*g3)(PetscInt, PetscInt, PetscInt,
10616528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10626528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10636528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
10646528b96dSMatthew G. Knepley {
10656528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
10666528b96dSMatthew G. Knepley   PetscErrorCode ierr;
10676528b96dSMatthew G. Knepley 
10686528b96dSMatthew G. Knepley   PetscFunctionBegin;
10696528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->gt0, label, val, find, (void (*)(void)) g0);CHKERRQ(ierr);
10706528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->gt1, label, val, find, (void (*)(void)) g1);CHKERRQ(ierr);
10716528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->gt2, label, val, find, (void (*)(void)) g2);CHKERRQ(ierr);
10726528b96dSMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->gt3, label, val, find, (void (*)(void)) g3);CHKERRQ(ierr);
10736528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
10746528b96dSMatthew G. Knepley }
10756528b96dSMatthew G. Knepley 
10766528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetDynamicJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
10776528b96dSMatthew G. Knepley                                                PetscInt n0,
10786528b96dSMatthew G. Knepley                                                void (**g0)(PetscInt, PetscInt, PetscInt,
10796528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10806528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10816528b96dSMatthew G. Knepley                                                           PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
10826528b96dSMatthew G. Knepley                                                PetscInt n1,
10836528b96dSMatthew G. Knepley                                                void (**g1)(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[], PetscInt, const PetscScalar[], PetscScalar[]),
10876528b96dSMatthew G. Knepley                                                PetscInt n2,
10886528b96dSMatthew G. Knepley                                                void (**g2)(PetscInt, PetscInt, PetscInt,
10896528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10906528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10916528b96dSMatthew G. Knepley                                                           PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
10926528b96dSMatthew G. Knepley                                                PetscInt n3,
10936528b96dSMatthew G. Knepley                                                void (**g3)(PetscInt, PetscInt, PetscInt,
10946528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10956528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10966528b96dSMatthew G. Knepley                                                           PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
10976528b96dSMatthew G. Knepley {
10986528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
10996528b96dSMatthew G. Knepley   PetscErrorCode ierr;
11006528b96dSMatthew G. Knepley 
11016528b96dSMatthew G. Knepley   PetscFunctionBegin;
11026528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->gt0, label, val, find, n0, (void (**)(void)) g0);CHKERRQ(ierr);
11036528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->gt1, label, val, find, n1, (void (**)(void)) g1);CHKERRQ(ierr);
11046528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->gt2, label, val, find, n2, (void (**)(void)) g2);CHKERRQ(ierr);
11056528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->gt3, label, val, find, n3, (void (**)(void)) g3);CHKERRQ(ierr);
11066528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
11076528b96dSMatthew G. Knepley }
11086528b96dSMatthew G. Knepley 
11096528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetIndexDynamicJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g,
11106528b96dSMatthew G. Knepley                                                PetscInt i0,
11116528b96dSMatthew G. Knepley                                                void (*g0)(PetscInt, PetscInt, PetscInt,
11126528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11136528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11146528b96dSMatthew G. Knepley                                                           PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
11156528b96dSMatthew G. Knepley                                                PetscInt i1,
11166528b96dSMatthew G. Knepley                                                void (*g1)(PetscInt, PetscInt, PetscInt,
11176528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11186528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11196528b96dSMatthew G. Knepley                                                           PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
11206528b96dSMatthew G. Knepley                                                PetscInt i2,
11216528b96dSMatthew G. Knepley                                                void (*g2)(PetscInt, PetscInt, PetscInt,
11226528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11236528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11246528b96dSMatthew G. Knepley                                                           PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
11256528b96dSMatthew G. Knepley                                                PetscInt i3,
11266528b96dSMatthew G. Knepley                                                void (*g3)(PetscInt, PetscInt, PetscInt,
11276528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11286528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11296528b96dSMatthew G. Knepley                                                           PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
11306528b96dSMatthew G. Knepley {
11316528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
11326528b96dSMatthew G. Knepley   PetscErrorCode ierr;
11336528b96dSMatthew G. Knepley 
11346528b96dSMatthew G. Knepley   PetscFunctionBegin;
11356528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->gt0, label, val, find, i0, (void (*)(void)) g0);CHKERRQ(ierr);
11366528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->gt1, label, val, find, i1, (void (*)(void)) g1);CHKERRQ(ierr);
11376528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->gt2, label, val, find, i2, (void (*)(void)) g2);CHKERRQ(ierr);
11386528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->gt3, label, val, find, i3, (void (*)(void)) g3);CHKERRQ(ierr);
11396528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
11406528b96dSMatthew G. Knepley }
11416528b96dSMatthew G. Knepley 
11426528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormGetRiemannSolver(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt *n,
11436528b96dSMatthew G. Knepley                                              void (***r)(PetscInt, PetscInt, const PetscReal[], const PetscReal[], const PetscScalar[], const PetscScalar[], PetscInt, const PetscScalar[], PetscScalar[], void *))
11446528b96dSMatthew G. Knepley {
11456528b96dSMatthew G. Knepley   PetscErrorCode ierr;
11466528b96dSMatthew G. Knepley 
11476528b96dSMatthew G. Knepley   PetscFunctionBegin;
11486528b96dSMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->r, label, val, f, n, (void (***)(void)) r);CHKERRQ(ierr);
11496528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
11506528b96dSMatthew G. Knepley }
11516528b96dSMatthew G. Knepley 
11526528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetRiemannSolver(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f,
11536528b96dSMatthew G. Knepley                                              PetscInt n,
11546528b96dSMatthew G. Knepley                                              void (**r)(PetscInt, PetscInt, const PetscReal[], const PetscReal[], const PetscScalar[], const PetscScalar[], PetscInt, const PetscScalar[], PetscScalar[], void *))
11556528b96dSMatthew G. Knepley {
11566528b96dSMatthew G. Knepley   PetscErrorCode ierr;
11576528b96dSMatthew G. Knepley 
11586528b96dSMatthew G. Knepley   PetscFunctionBegin;
11596528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->r, label, val, f, n, (void (**)(void)) r);CHKERRQ(ierr);
11606528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
11616528b96dSMatthew G. Knepley }
11626528b96dSMatthew G. Knepley 
11636528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetIndexRiemannSolver(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f,
11646528b96dSMatthew G. Knepley                                                   PetscInt i,
11656528b96dSMatthew G. Knepley                                                   void (*r)(PetscInt, PetscInt, const PetscReal[], const PetscReal[], const PetscScalar[], const PetscScalar[], PetscInt, const PetscScalar[], PetscScalar[], void *))
11666528b96dSMatthew G. Knepley {
11676528b96dSMatthew G. Knepley   PetscErrorCode ierr;
11686528b96dSMatthew G. Knepley 
11696528b96dSMatthew G. Knepley   PetscFunctionBegin;
11706528b96dSMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->r, label, val, f, i, (void (*)(void)) r);CHKERRQ(ierr);
11716528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
11726528b96dSMatthew G. Knepley }
11736528b96dSMatthew G. Knepley 
11746528b96dSMatthew G. Knepley /*@
11756528b96dSMatthew G. Knepley   PetscWeakFormGetNumFields - Returns the number of fields
11766528b96dSMatthew G. Knepley 
11776528b96dSMatthew G. Knepley   Not collective
11786528b96dSMatthew G. Knepley 
11796528b96dSMatthew G. Knepley   Input Parameter:
11806528b96dSMatthew G. Knepley . wf - The PetscWeakForm object
11816528b96dSMatthew G. Knepley 
11826528b96dSMatthew G. Knepley   Output Parameter:
11836528b96dSMatthew G. Knepley . Nf - The nubmer of fields
11846528b96dSMatthew G. Knepley 
11856528b96dSMatthew G. Knepley   Level: beginner
11866528b96dSMatthew G. Knepley 
11876528b96dSMatthew G. Knepley .seealso: PetscWeakFormSetNumFields(), PetscWeakFormCreate()
11886528b96dSMatthew G. Knepley @*/
11896528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormGetNumFields(PetscWeakForm wf, PetscInt *Nf)
11906528b96dSMatthew G. Knepley {
11916528b96dSMatthew G. Knepley   PetscFunctionBegin;
11926528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
11936528b96dSMatthew G. Knepley   PetscValidPointer(Nf, 2);
11946528b96dSMatthew G. Knepley   *Nf = wf->Nf;
11956528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
11966528b96dSMatthew G. Knepley }
11976528b96dSMatthew G. Knepley 
11986528b96dSMatthew G. Knepley /*@
11996528b96dSMatthew G. Knepley   PetscWeakFormSetNumFields - Sets the number of fields
12006528b96dSMatthew G. Knepley 
12016528b96dSMatthew G. Knepley   Not collective
12026528b96dSMatthew G. Knepley 
12036528b96dSMatthew G. Knepley   Input Parameters:
12046528b96dSMatthew G. Knepley + wf - The PetscWeakForm object
12056528b96dSMatthew G. Knepley - Nf - The number of fields
12066528b96dSMatthew G. Knepley 
12076528b96dSMatthew G. Knepley   Level: beginner
12086528b96dSMatthew G. Knepley 
12096528b96dSMatthew G. Knepley .seealso: PetscWeakFormGetNumFields(), PetscWeakFormCreate()
12106528b96dSMatthew G. Knepley @*/
12116528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetNumFields(PetscWeakForm wf, PetscInt Nf)
12126528b96dSMatthew G. Knepley {
12136528b96dSMatthew G. Knepley   PetscFunctionBegin;
12146528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
12156528b96dSMatthew G. Knepley   wf->Nf = Nf;
12166528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
12176528b96dSMatthew G. Knepley }
12186528b96dSMatthew G. Knepley 
12196528b96dSMatthew G. Knepley /*@
12206528b96dSMatthew G. Knepley   PetscWeakFormDestroy - Destroys a PetscWeakForm object
12216528b96dSMatthew G. Knepley 
12226528b96dSMatthew G. Knepley   Collective on wf
12236528b96dSMatthew G. Knepley 
12246528b96dSMatthew G. Knepley   Input Parameter:
12256528b96dSMatthew G. Knepley . wf - the PetscWeakForm object to destroy
12266528b96dSMatthew G. Knepley 
12276528b96dSMatthew G. Knepley   Level: developer
12286528b96dSMatthew G. Knepley 
12296528b96dSMatthew G. Knepley .seealso PetscWeakFormCreate(), PetscWeakFormView()
12306528b96dSMatthew G. Knepley @*/
12316528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormDestroy(PetscWeakForm *wf)
12326528b96dSMatthew G. Knepley {
12336528b96dSMatthew G. Knepley   PetscErrorCode ierr;
12346528b96dSMatthew G. Knepley 
12356528b96dSMatthew G. Knepley   PetscFunctionBegin;
12366528b96dSMatthew G. Knepley   if (!*wf) PetscFunctionReturn(0);
12376528b96dSMatthew G. Knepley   PetscValidHeaderSpecific((*wf), PETSCWEAKFORM_CLASSID, 1);
12386528b96dSMatthew G. Knepley 
12396528b96dSMatthew G. Knepley   if (--((PetscObject)(*wf))->refct > 0) {*wf = NULL; PetscFunctionReturn(0);}
12406528b96dSMatthew G. Knepley   ((PetscObject) (*wf))->refct = 0;
12416528b96dSMatthew G. Knepley   ierr = PetscChunkBufferDestroy(&(*wf)->funcs);CHKERRQ(ierr);
12426528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->obj);CHKERRQ(ierr);
12436528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->f0);CHKERRQ(ierr);
12446528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->f1);CHKERRQ(ierr);
12456528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->g0);CHKERRQ(ierr);
12466528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->g1);CHKERRQ(ierr);
12476528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->g2);CHKERRQ(ierr);
12486528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->g3);CHKERRQ(ierr);
12496528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->gp0);CHKERRQ(ierr);
12506528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->gp1);CHKERRQ(ierr);
12516528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->gp2);CHKERRQ(ierr);
12526528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->gp3);CHKERRQ(ierr);
12536528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->gt0);CHKERRQ(ierr);
12546528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->gt1);CHKERRQ(ierr);
12556528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->gt2);CHKERRQ(ierr);
12566528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->gt3);CHKERRQ(ierr);
12576528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->bdf0);CHKERRQ(ierr);
12586528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->bdf1);CHKERRQ(ierr);
12596528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->bdg0);CHKERRQ(ierr);
12606528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->bdg1);CHKERRQ(ierr);
12616528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->bdg2);CHKERRQ(ierr);
12626528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->bdg3);CHKERRQ(ierr);
12636528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->bdgp0);CHKERRQ(ierr);
12646528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->bdgp1);CHKERRQ(ierr);
12656528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->bdgp2);CHKERRQ(ierr);
12666528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->bdgp3);CHKERRQ(ierr);
12676528b96dSMatthew G. Knepley   ierr = PetscHMapFormDestroy(&(*wf)->r);CHKERRQ(ierr);
12686528b96dSMatthew G. Knepley   ierr = PetscHeaderDestroy(wf);CHKERRQ(ierr);
12696528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
12706528b96dSMatthew G. Knepley }
12716528b96dSMatthew G. Knepley 
12726528b96dSMatthew G. Knepley static PetscErrorCode PetscWeakFormViewTable_Ascii(PetscWeakForm wf, PetscViewer viewer, const char tableName[], PetscHMapForm map)
12736528b96dSMatthew G. Knepley {
12746528b96dSMatthew G. Knepley   PetscInt       Nk, k;
12756528b96dSMatthew G. Knepley   PetscErrorCode ierr;
12766528b96dSMatthew G. Knepley 
12776528b96dSMatthew G. Knepley   PetscFunctionBegin;
12786528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(map, &Nk);CHKERRQ(ierr);
12796528b96dSMatthew G. Knepley   if (Nk) {
12806528b96dSMatthew G. Knepley     PetscHashFormKey *keys;
12816528b96dSMatthew G. Knepley     void           (**funcs)(void);
12826528b96dSMatthew G. Knepley     const char       *name;
12836528b96dSMatthew G. Knepley     PetscInt          off = 0, n, i;
12846528b96dSMatthew G. Knepley 
12856528b96dSMatthew G. Knepley     ierr = PetscMalloc1(Nk, &keys);CHKERRQ(ierr);
12866528b96dSMatthew G. Knepley     ierr = PetscHMapFormGetKeys(map, &off, keys);CHKERRQ(ierr);
12876528b96dSMatthew G. Knepley     ierr = PetscViewerASCIIPrintf(viewer, "%s\n", tableName);CHKERRQ(ierr);
12886528b96dSMatthew G. Knepley     ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr);
12896528b96dSMatthew G. Knepley     for (k = 0; k < Nk; ++k) {
12906528b96dSMatthew G. Knepley       if (keys[k].label) {ierr = PetscObjectGetName((PetscObject) keys[k].label, &name);CHKERRQ(ierr);}
12916528b96dSMatthew G. Knepley       ierr = PetscViewerASCIIPrintf(viewer, "Key (%s, %D, %D) ", keys[k].label ? name : "None", keys[k].value, keys[k].field);CHKERRQ(ierr);
12926528b96dSMatthew G. Knepley       ierr = PetscViewerASCIIUseTabs(viewer, PETSC_FALSE);CHKERRQ(ierr);
12936528b96dSMatthew G. Knepley       ierr = PetscWeakFormGetFunction_Private(wf, map, keys[k].label, keys[k].value, keys[k].field, &n, &funcs);CHKERRQ(ierr);
12946528b96dSMatthew G. Knepley       for (i = 0; i < n; ++i) {
12956528b96dSMatthew G. Knepley         if (i > 0) {ierr = PetscViewerASCIIPrintf(viewer, ", ");CHKERRQ(ierr);}
12966528b96dSMatthew G. Knepley         ierr = PetscDLAddr(funcs[i], &name);CHKERRQ(ierr);
12976528b96dSMatthew G. Knepley         if (name) {ierr = PetscViewerASCIIPrintf(viewer, "%s", name);CHKERRQ(ierr);}
12986528b96dSMatthew G. Knepley         else      {ierr = PetscViewerASCIIPrintf(viewer, "%p", funcs[i]);CHKERRQ(ierr);}
12996528b96dSMatthew G. Knepley       }
13006528b96dSMatthew G. Knepley       ierr = PetscViewerASCIIPrintf(viewer, "\n");CHKERRQ(ierr);
13016528b96dSMatthew G. Knepley       ierr = PetscViewerASCIIUseTabs(viewer, PETSC_TRUE);CHKERRQ(ierr);
13026528b96dSMatthew G. Knepley     }
13036528b96dSMatthew G. Knepley     ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr);
13046528b96dSMatthew G. Knepley     ierr = PetscFree(keys);CHKERRQ(ierr);
13056528b96dSMatthew G. Knepley   }
13066528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
13076528b96dSMatthew G. Knepley }
13086528b96dSMatthew G. Knepley 
13096528b96dSMatthew G. Knepley static PetscErrorCode PetscWeakFormView_Ascii(PetscWeakForm wf, PetscViewer viewer)
13106528b96dSMatthew G. Knepley {
13116528b96dSMatthew G. Knepley   PetscViewerFormat format;
13126528b96dSMatthew G. Knepley   PetscErrorCode    ierr;
13136528b96dSMatthew G. Knepley 
13146528b96dSMatthew G. Knepley   PetscFunctionBegin;
13156528b96dSMatthew G. Knepley   ierr = PetscViewerGetFormat(viewer, &format);CHKERRQ(ierr);
13166528b96dSMatthew G. Knepley   ierr = PetscViewerASCIIPrintf(viewer, "Weak Form System with %d fields\n", wf->Nf);CHKERRQ(ierr);
13176528b96dSMatthew G. Knepley   ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr);
13186528b96dSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, "Objective", wf->obj);CHKERRQ(ierr);
13196528b96dSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, "Residual f0", wf->f0);CHKERRQ(ierr);
13206528b96dSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, "Residual f1", wf->f1);CHKERRQ(ierr);
13216528b96dSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, "Boudnary Residual f0", wf->bdf0);CHKERRQ(ierr);
13226528b96dSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, "Boundary Residual f1", wf->bdf1);CHKERRQ(ierr);
13236528b96dSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, "Jacobian g0", wf->g0);CHKERRQ(ierr);
13246528b96dSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, "Jacobian g1", wf->g1);CHKERRQ(ierr);
13256528b96dSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, "Jacobian g2", wf->g2);CHKERRQ(ierr);
13266528b96dSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, "Jacobian g3", wf->g3);CHKERRQ(ierr);
13276528b96dSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, "Jacobian Preconditioner g0", wf->gp0);CHKERRQ(ierr);
13286528b96dSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, "Jacobian Preconditioner g1", wf->gp1);CHKERRQ(ierr);
13296528b96dSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, "Jacobian Preconditioner g2", wf->gp2);CHKERRQ(ierr);
13306528b96dSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, "Jacobian Preconditioner g3", wf->gp3);CHKERRQ(ierr);
13316528b96dSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, "Dynamic Jacobian g0", wf->gt0);CHKERRQ(ierr);
13326528b96dSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, "Dynamic Jacobian g1", wf->gt1);CHKERRQ(ierr);
13336528b96dSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, "Dynamic Jacobian g2", wf->gt2);CHKERRQ(ierr);
13346528b96dSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, "Dynamic Jacobian g3", wf->gt3);CHKERRQ(ierr);
13356528b96dSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, "Boundary Jacobian g0", wf->bdg0);CHKERRQ(ierr);
13366528b96dSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, "Boundary Jacobian g1", wf->bdg1);CHKERRQ(ierr);
13376528b96dSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, "Boundary Jacobian g2", wf->bdg2);CHKERRQ(ierr);
13386528b96dSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, "Boundary Jacobian g3", wf->bdg3);CHKERRQ(ierr);
13396528b96dSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, "Boundary Jacobian Preconditioner g0", wf->bdgp0);CHKERRQ(ierr);
13406528b96dSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, "Boundary Jacobian Preconditioner g1", wf->bdgp1);CHKERRQ(ierr);
13416528b96dSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, "Boundary Jacobian Preconditioner g2", wf->bdgp2);CHKERRQ(ierr);
13426528b96dSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, "Boundary Jacobian Preconditioner g3", wf->bdgp3);CHKERRQ(ierr);
13436528b96dSMatthew G. Knepley   ierr = PetscWeakFormViewTable_Ascii(wf, viewer, "Riemann Solver", wf->r);CHKERRQ(ierr);
13446528b96dSMatthew G. Knepley   ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr);
13456528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
13466528b96dSMatthew G. Knepley }
13476528b96dSMatthew G. Knepley 
13486528b96dSMatthew G. Knepley /*@C
13496528b96dSMatthew G. Knepley   PetscWeakFormView - Views a PetscWeakForm
13506528b96dSMatthew G. Knepley 
13516528b96dSMatthew G. Knepley   Collective on wf
13526528b96dSMatthew G. Knepley 
13536528b96dSMatthew G. Knepley   Input Parameter:
13546528b96dSMatthew G. Knepley + wf - the PetscWeakForm object to view
13556528b96dSMatthew G. Knepley - v  - the viewer
13566528b96dSMatthew G. Knepley 
13576528b96dSMatthew G. Knepley   Level: developer
13586528b96dSMatthew G. Knepley 
13596528b96dSMatthew G. Knepley .seealso PetscWeakFormDestroy(), PetscWeakFormCreate()
13606528b96dSMatthew G. Knepley @*/
13616528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormView(PetscWeakForm wf, PetscViewer v)
13626528b96dSMatthew G. Knepley {
13636528b96dSMatthew G. Knepley   PetscBool      iascii;
13646528b96dSMatthew G. Knepley   PetscErrorCode ierr;
13656528b96dSMatthew G. Knepley 
13666528b96dSMatthew G. Knepley   PetscFunctionBegin;
13676528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
13686528b96dSMatthew G. Knepley   if (!v) {ierr = PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject) wf), &v);CHKERRQ(ierr);}
13696528b96dSMatthew G. Knepley   else    {PetscValidHeaderSpecific(v, PETSC_VIEWER_CLASSID, 2);}
13706528b96dSMatthew G. Knepley   ierr = PetscObjectTypeCompare((PetscObject) v, PETSCVIEWERASCII, &iascii);CHKERRQ(ierr);
13716528b96dSMatthew G. Knepley   if (iascii) {ierr = PetscWeakFormView_Ascii(wf, v);CHKERRQ(ierr);}
13726528b96dSMatthew G. Knepley   if (wf->ops->view) {ierr = (*wf->ops->view)(wf, v);CHKERRQ(ierr);}
13736528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
13746528b96dSMatthew G. Knepley }
13756528b96dSMatthew G. Knepley 
13766528b96dSMatthew G. Knepley /*@
13776528b96dSMatthew G. Knepley   PetscWeakFormCreate - Creates an empty PetscWeakForm object.
13786528b96dSMatthew G. Knepley 
13796528b96dSMatthew G. Knepley   Collective
13806528b96dSMatthew G. Knepley 
13816528b96dSMatthew G. Knepley   Input Parameter:
13826528b96dSMatthew G. Knepley . comm - The communicator for the PetscWeakForm object
13836528b96dSMatthew G. Knepley 
13846528b96dSMatthew G. Knepley   Output Parameter:
13856528b96dSMatthew G. Knepley . wf - The PetscWeakForm object
13866528b96dSMatthew G. Knepley 
13876528b96dSMatthew G. Knepley   Level: beginner
13886528b96dSMatthew G. Knepley 
13896528b96dSMatthew G. Knepley .seealso: PetscDS, PetscWeakFormDestroy()
13906528b96dSMatthew G. Knepley @*/
13916528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormCreate(MPI_Comm comm, PetscWeakForm *wf)
13926528b96dSMatthew G. Knepley {
13936528b96dSMatthew G. Knepley   PetscWeakForm  p;
13946528b96dSMatthew G. Knepley   PetscErrorCode ierr;
13956528b96dSMatthew G. Knepley 
13966528b96dSMatthew G. Knepley   PetscFunctionBegin;
13976528b96dSMatthew G. Knepley   PetscValidPointer(wf, 2);
13986528b96dSMatthew G. Knepley   *wf  = NULL;
13996528b96dSMatthew G. Knepley   ierr = PetscDSInitializePackage();CHKERRQ(ierr);
14006528b96dSMatthew G. Knepley 
14016528b96dSMatthew G. Knepley   ierr = PetscHeaderCreate(p, PETSCWEAKFORM_CLASSID, "PetscWeakForm", "Weak Form System", "PetscWeakForm", comm, PetscWeakFormDestroy, PetscWeakFormView);CHKERRQ(ierr);
14026528b96dSMatthew G. Knepley 
14036528b96dSMatthew G. Knepley   p->Nf = 0;
14046528b96dSMatthew G. Knepley   ierr = PetscChunkBufferCreate(sizeof(&PetscWeakFormCreate), 2, &p->funcs);CHKERRQ(ierr);
14056528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->obj);CHKERRQ(ierr);
14066528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->f0);CHKERRQ(ierr);
14076528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->f1);CHKERRQ(ierr);
14086528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->g0);CHKERRQ(ierr);
14096528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->g1);CHKERRQ(ierr);
14106528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->g2);CHKERRQ(ierr);
14116528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->g3);CHKERRQ(ierr);
14126528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->gp0);CHKERRQ(ierr);
14136528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->gp1);CHKERRQ(ierr);
14146528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->gp2);CHKERRQ(ierr);
14156528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->gp3);CHKERRQ(ierr);
14166528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->gt0);CHKERRQ(ierr);
14176528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->gt1);CHKERRQ(ierr);
14186528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->gt2);CHKERRQ(ierr);
14196528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->gt3);CHKERRQ(ierr);
14206528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->bdf0);CHKERRQ(ierr);
14216528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->bdf1);CHKERRQ(ierr);
14226528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->bdg0);CHKERRQ(ierr);
14236528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->bdg1);CHKERRQ(ierr);
14246528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->bdg2);CHKERRQ(ierr);
14256528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->bdg3);CHKERRQ(ierr);
14266528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->bdgp0);CHKERRQ(ierr);
14276528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->bdgp1);CHKERRQ(ierr);
14286528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->bdgp2);CHKERRQ(ierr);
14296528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->bdgp3);CHKERRQ(ierr);
14306528b96dSMatthew G. Knepley   ierr = PetscHMapFormCreate(&p->r);CHKERRQ(ierr);
14316528b96dSMatthew G. Knepley   *wf = p;
14326528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
14336528b96dSMatthew G. Knepley }
1434