xref: /petsc/src/dm/dt/interface/dtweakform.c (revision 06ad157546d036f7e09b18c4984a823580aab6f1)
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 
5*06ad1575SMatthew G. Knepley const char *const PetscWeakFormKinds[] = {"objective", "residual_f0", "residual_f1", "jacobian_g0", "jacobian_g1", "jacobian_g2", "jacobian_g3", "jacobian_preconditioner_g0", "jacobian_preconditioner_g1", "jacobian_preconditioner_g2", "jacobian_preconditioner_g3", "dynamic_jacobian_g0", "dynamic_jacobian_g1", "dynamic_jacobian_g2", "dynamic_jacobian_g3", "boundary_residual_f0", "boundary_residual_f1", "boundary_jacobian_g0", "boundary_jacobian_g1", "boundary_jacobian_g2", "boundary_jacobian_g3", "boundary_jacobian_preconditioner_g0", "boundary_jacobian_preconditioner_g1", "boundary_jacobian_preconditioner_g2", "boundary_jacobian_preconditioner_g3", "riemann_solver", "PetscWeakFormKind", "PETSC_WF_", NULL};
6*06ad1575SMatthew G. Knepley 
76528b96dSMatthew G. Knepley static PetscErrorCode PetscChunkBufferCreate(size_t unitbytes, size_t expected, PetscChunkBuffer **buffer)
86528b96dSMatthew G. Knepley {
96528b96dSMatthew G. Knepley   PetscErrorCode ierr;
106528b96dSMatthew G. Knepley 
116528b96dSMatthew G. Knepley   PetscFunctionBegin;
126528b96dSMatthew G. Knepley   ierr = PetscNew(buffer);CHKERRQ(ierr);
136528b96dSMatthew G. Knepley   ierr = PetscCalloc1(expected*unitbytes, &(*buffer)->array);CHKERRQ(ierr);
146528b96dSMatthew G. Knepley   (*buffer)->size      = expected;
156528b96dSMatthew G. Knepley   (*buffer)->unitbytes = unitbytes;
166528b96dSMatthew G. Knepley   (*buffer)->alloc     = expected*unitbytes;
176528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
186528b96dSMatthew G. Knepley }
196528b96dSMatthew G. Knepley 
2045480ffeSMatthew G. Knepley static PetscErrorCode PetscChunkBufferDuplicate(PetscChunkBuffer *buffer, PetscChunkBuffer **bufferNew)
2145480ffeSMatthew G. Knepley {
2245480ffeSMatthew G. Knepley   PetscErrorCode ierr;
2345480ffeSMatthew G. Knepley 
2445480ffeSMatthew G. Knepley   PetscFunctionBegin;
2545480ffeSMatthew G. Knepley   ierr = PetscNew(bufferNew);CHKERRQ(ierr);
2645480ffeSMatthew G. Knepley   ierr = PetscCalloc1(buffer->size*buffer->unitbytes, &(*bufferNew)->array);CHKERRQ(ierr);
2745480ffeSMatthew G. Knepley   ierr = PetscMemcpy((*bufferNew)->array, buffer->array, buffer->size*buffer->unitbytes);CHKERRQ(ierr);
2845480ffeSMatthew G. Knepley   (*bufferNew)->size      = buffer->size;
2945480ffeSMatthew G. Knepley   (*bufferNew)->unitbytes = buffer->unitbytes;
3045480ffeSMatthew G. Knepley   (*bufferNew)->alloc     = buffer->size*buffer->unitbytes;
3145480ffeSMatthew G. Knepley   PetscFunctionReturn(0);
3245480ffeSMatthew G. Knepley }
3345480ffeSMatthew G. Knepley 
346528b96dSMatthew G. Knepley static PetscErrorCode PetscChunkBufferDestroy(PetscChunkBuffer **buffer)
356528b96dSMatthew G. Knepley {
366528b96dSMatthew G. Knepley   PetscErrorCode ierr;
376528b96dSMatthew G. Knepley 
386528b96dSMatthew G. Knepley   PetscFunctionBegin;
396528b96dSMatthew G. Knepley   ierr = PetscFree((*buffer)->array);CHKERRQ(ierr);
406528b96dSMatthew G. Knepley   ierr = PetscFree(*buffer);CHKERRQ(ierr);
416528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
426528b96dSMatthew G. Knepley }
436528b96dSMatthew G. Knepley 
446528b96dSMatthew G. Knepley static PetscErrorCode PetscChunkBufferCreateChunk(PetscChunkBuffer *buffer, PetscInt size, PetscChunk *chunk)
456528b96dSMatthew G. Knepley {
466528b96dSMatthew G. Knepley   PetscErrorCode ierr;
476528b96dSMatthew G. Knepley 
486528b96dSMatthew G. Knepley   PetscFunctionBegin;
496528b96dSMatthew G. Knepley   if ((buffer->size + size)*buffer->unitbytes > buffer->alloc) {
506528b96dSMatthew G. Knepley     char *tmp;
516528b96dSMatthew G. Knepley 
526528b96dSMatthew G. Knepley     if (!buffer->alloc) buffer->alloc = (buffer->size + size)*buffer->unitbytes;
536528b96dSMatthew G. Knepley     while ((buffer->size + size)*buffer->unitbytes > buffer->alloc) buffer->alloc *= 2;
546528b96dSMatthew G. Knepley     ierr = PetscMalloc(buffer->alloc, &tmp);CHKERRQ(ierr);
556528b96dSMatthew G. Knepley     ierr = PetscMemcpy(tmp, buffer->array, buffer->size*buffer->unitbytes);CHKERRQ(ierr);
566528b96dSMatthew G. Knepley     ierr = PetscFree(buffer->array);CHKERRQ(ierr);
576528b96dSMatthew G. Knepley     buffer->array = tmp;
586528b96dSMatthew G. Knepley   }
592baeeceeSMatthew G. Knepley   chunk->start    = buffer->size*buffer->unitbytes;
606528b96dSMatthew G. Knepley   chunk->size     = size;
616528b96dSMatthew G. Knepley   chunk->reserved = size;
626528b96dSMatthew G. Knepley   buffer->size   += size;
636528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
646528b96dSMatthew G. Knepley }
656528b96dSMatthew G. Knepley 
666528b96dSMatthew G. Knepley static PetscErrorCode PetscChunkBufferEnlargeChunk(PetscChunkBuffer *buffer, PetscInt size, PetscChunk *chunk)
676528b96dSMatthew G. Knepley {
686528b96dSMatthew G. Knepley   size_t         siz = size;
696528b96dSMatthew G. Knepley   PetscErrorCode ierr;
706528b96dSMatthew G. Knepley 
716528b96dSMatthew G. Knepley   PetscFunctionBegin;
726528b96dSMatthew G. Knepley   if (chunk->size + size > chunk->reserved) {
736528b96dSMatthew G. Knepley     PetscChunk newchunk;
746528b96dSMatthew G. Knepley     PetscInt   reserved = chunk->size;
756528b96dSMatthew G. Knepley 
766528b96dSMatthew G. Knepley     /* TODO Here if we had a chunk list, we could update them all to reclaim unused space */
776528b96dSMatthew G. Knepley     while (reserved < chunk->size+size) reserved *= 2;
786528b96dSMatthew G. Knepley     ierr = PetscChunkBufferCreateChunk(buffer, (size_t) reserved, &newchunk);CHKERRQ(ierr);
796528b96dSMatthew G. Knepley     newchunk.size = chunk->size+size;
806528b96dSMatthew G. Knepley     ierr = PetscMemcpy(&buffer->array[newchunk.start], &buffer->array[chunk->start], chunk->size * buffer->unitbytes);CHKERRQ(ierr);
816528b96dSMatthew G. Knepley     *chunk = newchunk;
826528b96dSMatthew G. Knepley   } else {
836528b96dSMatthew G. Knepley     chunk->size += siz;
846528b96dSMatthew G. Knepley   }
856528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
866528b96dSMatthew G. Knepley }
876528b96dSMatthew G. Knepley 
886528b96dSMatthew G. Knepley /*@C
89*06ad1575SMatthew G. Knepley   PetscFormKeySort - Sorts an array of PetscFormKey in place in increasing order.
906528b96dSMatthew G. Knepley 
916528b96dSMatthew G. Knepley   Not Collective
926528b96dSMatthew G. Knepley 
936528b96dSMatthew G. Knepley   Input Parameters:
946528b96dSMatthew G. Knepley + n - number of values
95*06ad1575SMatthew G. Knepley - X - array of PetscFormKey
966528b96dSMatthew G. Knepley 
976528b96dSMatthew G. Knepley   Level: intermediate
986528b96dSMatthew G. Knepley 
996528b96dSMatthew G. Knepley .seealso: PetscIntSortSemiOrdered(), PetscSortInt()
1006528b96dSMatthew G. Knepley @*/
101*06ad1575SMatthew G. Knepley PetscErrorCode PetscFormKeySort(PetscInt n, PetscFormKey arr[])
1026528b96dSMatthew G. Knepley {
1036528b96dSMatthew G. Knepley   PetscErrorCode ierr;
1046528b96dSMatthew G. Knepley 
1056528b96dSMatthew G. Knepley   PetscFunctionBegin;
1066528b96dSMatthew G. Knepley   if (n <= 1) PetscFunctionReturn(0);
1076528b96dSMatthew G. Knepley   PetscValidPointer(arr, 2);
108*06ad1575SMatthew G. Knepley   ierr = PetscTimSort(n, arr, sizeof(PetscFormKey), Compare_PetscFormKey_Private, NULL);CHKERRQ(ierr);
1096528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
1106528b96dSMatthew G. Knepley }
1116528b96dSMatthew G. Knepley 
112*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormGetFunction_Private(PetscWeakForm wf, PetscHMapForm ht, DMLabel label, PetscInt value, PetscInt f, PetscInt part, PetscInt *n, void (***func)())
1136528b96dSMatthew G. Knepley {
114*06ad1575SMatthew G. Knepley   PetscFormKey   key;
1156528b96dSMatthew G. Knepley   PetscChunk     chunk;
1166528b96dSMatthew G. Knepley   PetscErrorCode ierr;
1176528b96dSMatthew G. Knepley 
1186528b96dSMatthew G. Knepley   PetscFunctionBegin;
119*06ad1575SMatthew G. Knepley   key.label = label; key.value = value; key.field = f; key.part = part;
1206528b96dSMatthew G. Knepley   ierr = PetscHMapFormGet(ht, key, &chunk);CHKERRQ(ierr);
1216528b96dSMatthew G. Knepley   if (chunk.size < 0) {*n = 0;          *func = NULL;}
1222baeeceeSMatthew G. Knepley   else                {*n = chunk.size; *func = (void (**)()) &wf->funcs->array[chunk.start];}
1236528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
1246528b96dSMatthew G. Knepley }
1256528b96dSMatthew G. Knepley 
1266528b96dSMatthew G. Knepley /* A NULL argument for func causes this to clear the key */
127*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormSetFunction_Private(PetscWeakForm wf, PetscHMapForm ht, DMLabel label, PetscInt value, PetscInt f, PetscInt part, PetscInt n, void (**func)())
1286528b96dSMatthew G. Knepley {
129*06ad1575SMatthew G. Knepley   PetscFormKey   key;
1306528b96dSMatthew G. Knepley   PetscChunk     chunk;
1316528b96dSMatthew G. Knepley   PetscInt       i;
1326528b96dSMatthew G. Knepley   PetscErrorCode ierr;
1336528b96dSMatthew G. Knepley 
1346528b96dSMatthew G. Knepley   PetscFunctionBegin;
135*06ad1575SMatthew G. Knepley   key.label = label; key.value = value; key.field = f; key.part = part;
1366528b96dSMatthew G. Knepley   if (!func) {
1376528b96dSMatthew G. Knepley     ierr = PetscHMapFormDel(ht, key);CHKERRQ(ierr);
1386528b96dSMatthew G. Knepley     PetscFunctionReturn(0);
1396528b96dSMatthew G. Knepley   } else {
1406528b96dSMatthew G. Knepley     ierr = PetscHMapFormGet(ht, key, &chunk);CHKERRQ(ierr);
1416528b96dSMatthew G. Knepley   }
1426528b96dSMatthew G. Knepley   if (chunk.size < 0) {
1436528b96dSMatthew G. Knepley     ierr = PetscChunkBufferCreateChunk(wf->funcs, n, &chunk);CHKERRQ(ierr);
1446528b96dSMatthew G. Knepley     ierr = PetscHMapFormSet(ht, key, chunk);CHKERRQ(ierr);
1456528b96dSMatthew G. Knepley   } else if (chunk.size <= n) {
1466528b96dSMatthew G. Knepley     ierr = PetscChunkBufferEnlargeChunk(wf->funcs, n - chunk.size, &chunk);CHKERRQ(ierr);
1476528b96dSMatthew G. Knepley     ierr = PetscHMapFormSet(ht, key, chunk);CHKERRQ(ierr);
1486528b96dSMatthew G. Knepley   }
1492baeeceeSMatthew G. Knepley   for (i = 0; i < n; ++i) ((void (**)()) &wf->funcs->array[chunk.start])[i] = func[i];
1506528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
1516528b96dSMatthew G. Knepley }
1526528b96dSMatthew G. Knepley 
153*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormAddFunction_Private(PetscWeakForm wf, PetscHMapForm ht, DMLabel label, PetscInt value, PetscInt f, PetscInt part, void (*func)())
1546528b96dSMatthew G. Knepley {
155*06ad1575SMatthew G. Knepley   PetscFormKey   key;
1566528b96dSMatthew G. Knepley   PetscChunk     chunk;
1576528b96dSMatthew G. Knepley   PetscErrorCode ierr;
1586528b96dSMatthew G. Knepley 
1596528b96dSMatthew G. Knepley   PetscFunctionBegin;
1606528b96dSMatthew G. Knepley   if (!func) PetscFunctionReturn(0);
161*06ad1575SMatthew G. Knepley   key.label = label; key.value = value; key.field = f; key.part = part;
1626528b96dSMatthew G. Knepley   ierr = PetscHMapFormGet(ht, key, &chunk);CHKERRQ(ierr);
1636528b96dSMatthew G. Knepley   if (chunk.size < 0) {
1646528b96dSMatthew G. Knepley     ierr = PetscChunkBufferCreateChunk(wf->funcs, 1, &chunk);CHKERRQ(ierr);
1656528b96dSMatthew G. Knepley     ierr = PetscHMapFormSet(ht, key, chunk);CHKERRQ(ierr);
1662baeeceeSMatthew G. Knepley     ((void (**)()) &wf->funcs->array[chunk.start])[0] = func;
1676528b96dSMatthew G. Knepley   } else {
1686528b96dSMatthew G. Knepley     ierr = PetscChunkBufferEnlargeChunk(wf->funcs, 1, &chunk);CHKERRQ(ierr);
1696528b96dSMatthew G. Knepley     ierr = PetscHMapFormSet(ht, key, chunk);CHKERRQ(ierr);
1702baeeceeSMatthew G. Knepley     ((void (**)()) &wf->funcs->array[chunk.start])[chunk.size-1] = func;
1716528b96dSMatthew G. Knepley   }
1726528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
1736528b96dSMatthew G. Knepley }
1746528b96dSMatthew G. Knepley 
175*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormGetIndexFunction_Private(PetscWeakForm wf, PetscHMapForm ht, DMLabel label, PetscInt value, PetscInt f, PetscInt part, PetscInt ind, void (**func)())
1766528b96dSMatthew G. Knepley {
177*06ad1575SMatthew G. Knepley   PetscFormKey key;
1786528b96dSMatthew G. Knepley   PetscChunk       chunk;
1796528b96dSMatthew G. Knepley   PetscErrorCode   ierr;
1806528b96dSMatthew G. Knepley 
1816528b96dSMatthew G. Knepley   PetscFunctionBegin;
182*06ad1575SMatthew G. Knepley   key.label = label; key.value = value; key.field = f; key.part = part;
1836528b96dSMatthew G. Knepley   ierr = PetscHMapFormGet(ht, key, &chunk);CHKERRQ(ierr);
1846528b96dSMatthew G. Knepley   if (chunk.size < 0) {*func = NULL;}
1856528b96dSMatthew G. Knepley   else {
1866528b96dSMatthew G. Knepley     if (ind >= chunk.size) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Index %D not in [0, %D)", ind, chunk.size);
1872baeeceeSMatthew G. Knepley     *func = ((void (**)()) &wf->funcs->array[chunk.start])[ind];
1886528b96dSMatthew G. Knepley   }
1896528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
1906528b96dSMatthew G. Knepley }
1916528b96dSMatthew G. Knepley 
192*06ad1575SMatthew G. Knepley /* Ignore a NULL func */
193*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormSetIndexFunction_Private(PetscWeakForm wf, PetscHMapForm ht, DMLabel label, PetscInt value, PetscInt f, PetscInt part, PetscInt ind, void (*func)())
1946528b96dSMatthew G. Knepley {
195*06ad1575SMatthew G. Knepley   PetscFormKey key;
1966528b96dSMatthew G. Knepley   PetscChunk       chunk;
1976528b96dSMatthew G. Knepley   PetscErrorCode   ierr;
1986528b96dSMatthew G. Knepley 
1996528b96dSMatthew G. Knepley   PetscFunctionBegin;
200*06ad1575SMatthew G. Knepley   if (!func) PetscFunctionReturn(0);
201*06ad1575SMatthew G. Knepley   key.label = label; key.value = value; key.field = f; key.part = part;
2026528b96dSMatthew G. Knepley   ierr = PetscHMapFormGet(ht, key, &chunk);CHKERRQ(ierr);
2036528b96dSMatthew G. Knepley   if (chunk.size < 0) {
2046528b96dSMatthew G. Knepley     ierr = PetscChunkBufferCreateChunk(wf->funcs, ind+1, &chunk);CHKERRQ(ierr);
2056528b96dSMatthew G. Knepley     ierr = PetscHMapFormSet(ht, key, chunk);CHKERRQ(ierr);
2066528b96dSMatthew G. Knepley   } else if (chunk.size <= ind) {
2076528b96dSMatthew G. Knepley     ierr = PetscChunkBufferEnlargeChunk(wf->funcs, ind - chunk.size + 1, &chunk);CHKERRQ(ierr);
2086528b96dSMatthew G. Knepley     ierr = PetscHMapFormSet(ht, key, chunk);CHKERRQ(ierr);
2096528b96dSMatthew G. Knepley   }
2102baeeceeSMatthew G. Knepley   ((void (**)()) &wf->funcs->array[chunk.start])[ind] = func;
2116528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
2126528b96dSMatthew G. Knepley }
2136528b96dSMatthew G. Knepley 
214*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormClearIndexFunction_Private(PetscWeakForm wf, PetscHMapForm ht, DMLabel label, PetscInt value, PetscInt f, PetscInt part, PetscInt ind)
215*06ad1575SMatthew G. Knepley {
216*06ad1575SMatthew G. Knepley   PetscFormKey key;
217*06ad1575SMatthew G. Knepley   PetscChunk       chunk;
218*06ad1575SMatthew G. Knepley   PetscErrorCode   ierr;
219*06ad1575SMatthew G. Knepley 
220*06ad1575SMatthew G. Knepley   PetscFunctionBegin;
221*06ad1575SMatthew G. Knepley   key.label = label; key.value = value; key.field = f; key.part = part;
222*06ad1575SMatthew G. Knepley   ierr = PetscHMapFormGet(ht, key, &chunk);CHKERRQ(ierr);
223*06ad1575SMatthew G. Knepley   if (chunk.size < 0) {
224*06ad1575SMatthew G. Knepley     PetscFunctionReturn(0);
225*06ad1575SMatthew G. Knepley   } else if (!ind && chunk.size == 1) {
226*06ad1575SMatthew G. Knepley     ierr = PetscHMapFormDel(ht, key);CHKERRQ(ierr);
227*06ad1575SMatthew G. Knepley     PetscFunctionReturn(0);
228*06ad1575SMatthew G. Knepley   } else if (chunk.size <= ind) {
229*06ad1575SMatthew G. Knepley     PetscFunctionReturn(0);
230*06ad1575SMatthew G. Knepley   }
231*06ad1575SMatthew G. Knepley   ((void (**)()) &wf->funcs->array[chunk.start])[ind] = NULL;
232*06ad1575SMatthew G. Knepley   PetscFunctionReturn(0);
233*06ad1575SMatthew G. Knepley }
234*06ad1575SMatthew G. Knepley 
23545480ffeSMatthew G. Knepley /*@
23645480ffeSMatthew G. Knepley   PetscWeakFormCopy - Copy the pointwise functions to another PetscWeakForm
23745480ffeSMatthew G. Knepley 
23845480ffeSMatthew G. Knepley   Not Collective
23945480ffeSMatthew G. Knepley 
24045480ffeSMatthew G. Knepley   Input Parameter:
24145480ffeSMatthew G. Knepley . wf - The original PetscWeakForm
24245480ffeSMatthew G. Knepley 
24345480ffeSMatthew G. Knepley   Output Parameter:
24445480ffeSMatthew G. Knepley . wfNew - The copy PetscWeakForm
24545480ffeSMatthew G. Knepley 
24645480ffeSMatthew G. Knepley   Level: intermediate
24745480ffeSMatthew G. Knepley 
24845480ffeSMatthew G. Knepley .seealso: PetscWeakFormCreate(), PetscWeakFormDestroy()
24945480ffeSMatthew G. Knepley @*/
25045480ffeSMatthew G. Knepley PetscErrorCode PetscWeakFormCopy(PetscWeakForm wf, PetscWeakForm wfNew)
25145480ffeSMatthew G. Knepley {
252*06ad1575SMatthew G. Knepley   PetscInt       f;
25345480ffeSMatthew G. Knepley   PetscErrorCode ierr;
25445480ffeSMatthew G. Knepley 
25545480ffeSMatthew G. Knepley   PetscFunctionBegin;
25645480ffeSMatthew G. Knepley   wfNew->Nf = wf->Nf;
25745480ffeSMatthew G. Knepley   ierr = PetscChunkBufferDestroy(&wfNew->funcs);CHKERRQ(ierr);
25845480ffeSMatthew G. Knepley   ierr = PetscChunkBufferDuplicate(wf->funcs, &wfNew->funcs);CHKERRQ(ierr);
259*06ad1575SMatthew G. Knepley   for (f = 0; f < PETSC_NUM_WF; ++f) {
260*06ad1575SMatthew G. Knepley     ierr = PetscHMapFormDestroy(&wfNew->form[f]);CHKERRQ(ierr);
261*06ad1575SMatthew G. Knepley     ierr = PetscHMapFormDuplicate(wf->form[f], &wfNew->form[f]);CHKERRQ(ierr);
262*06ad1575SMatthew G. Knepley   }
263*06ad1575SMatthew G. Knepley   PetscFunctionReturn(0);
264*06ad1575SMatthew G. Knepley }
265*06ad1575SMatthew G. Knepley 
266*06ad1575SMatthew G. Knepley /*@
267*06ad1575SMatthew G. Knepley   PetscWeakFormClear - Clear all functions from the PetscWeakForm
268*06ad1575SMatthew G. Knepley 
269*06ad1575SMatthew G. Knepley   Not Collective
270*06ad1575SMatthew G. Knepley 
271*06ad1575SMatthew G. Knepley   Input Parameter:
272*06ad1575SMatthew G. Knepley . wf - The original PetscWeakForm
273*06ad1575SMatthew G. Knepley 
274*06ad1575SMatthew G. Knepley   Level: intermediate
275*06ad1575SMatthew G. Knepley 
276*06ad1575SMatthew G. Knepley .seealso: PetscWeakFormCopy(), PetscWeakFormCreate(), PetscWeakFormDestroy()
277*06ad1575SMatthew G. Knepley @*/
278*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormClear(PetscWeakForm wf)
279*06ad1575SMatthew G. Knepley {
280*06ad1575SMatthew G. Knepley   PetscInt       f;
281*06ad1575SMatthew G. Knepley   PetscErrorCode ierr;
282*06ad1575SMatthew G. Knepley 
283*06ad1575SMatthew G. Knepley   PetscFunctionBegin;
284*06ad1575SMatthew G. Knepley   for (f = 0; f < PETSC_NUM_WF; ++f) {ierr = PetscHMapFormClear(wf->form[f]);CHKERRQ(ierr);}
28545480ffeSMatthew G. Knepley   PetscFunctionReturn(0);
28645480ffeSMatthew G. Knepley }
28745480ffeSMatthew G. Knepley 
28845480ffeSMatthew G. Knepley static PetscErrorCode PetscWeakFormRewriteKeys_Internal(PetscWeakForm wf, PetscHMapForm hmap, DMLabel label, PetscInt Nv, const PetscInt values[])
28945480ffeSMatthew G. Knepley {
290*06ad1575SMatthew G. Knepley   PetscFormKey *keys;
29145480ffeSMatthew G. Knepley   PetscInt          n, i, v, off = 0;
29245480ffeSMatthew G. Knepley   PetscErrorCode    ierr;
29345480ffeSMatthew G. Knepley 
29445480ffeSMatthew G. Knepley   PetscFunctionBegin;
29545480ffeSMatthew G. Knepley   ierr = PetscHMapFormGetSize(hmap, &n);CHKERRQ(ierr);
29645480ffeSMatthew G. Knepley   ierr = PetscMalloc1(n, &keys);CHKERRQ(ierr);
29745480ffeSMatthew G. Knepley   ierr = PetscHMapFormGetKeys(hmap, &off, keys);CHKERRQ(ierr);
29845480ffeSMatthew G. Knepley   for (i = 0; i < n; ++i) {
29945480ffeSMatthew G. Knepley     if (keys[i].label == label) {
30045480ffeSMatthew G. Knepley       PetscBool clear = PETSC_TRUE;
30145480ffeSMatthew G. Knepley       void   (**funcs)();
30245480ffeSMatthew G. Knepley       PetscInt  Nf;
30345480ffeSMatthew G. Knepley 
304*06ad1575SMatthew G. Knepley       ierr = PetscWeakFormGetFunction_Private(wf, hmap, keys[i].label, keys[i].value, keys[i].field, keys[i].part, &Nf, &funcs);CHKERRQ(ierr);
30545480ffeSMatthew G. Knepley       for (v = 0; v < Nv; ++v) {
306*06ad1575SMatthew G. Knepley         ierr = PetscWeakFormSetFunction_Private(wf, hmap, keys[i].label, values[v], keys[i].field, keys[i].part, Nf, funcs);CHKERRQ(ierr);
30745480ffeSMatthew G. Knepley         if (values[v] == keys[i].value) clear = PETSC_FALSE;
30845480ffeSMatthew G. Knepley       }
309*06ad1575SMatthew G. Knepley       if (clear) {ierr = PetscWeakFormSetFunction_Private(wf, hmap, keys[i].label, keys[i].value, keys[i].field, keys[i].part, 0, NULL);CHKERRQ(ierr);}
31045480ffeSMatthew G. Knepley     }
31145480ffeSMatthew G. Knepley   }
31245480ffeSMatthew G. Knepley   ierr = PetscFree(keys);CHKERRQ(ierr);
31345480ffeSMatthew G. Knepley   PetscFunctionReturn(0);
31445480ffeSMatthew G. Knepley }
31545480ffeSMatthew G. Knepley 
31645480ffeSMatthew G. Knepley /*@C
31745480ffeSMatthew G. Knepley   PetscWeakFormRewriteKeys - Change any key on the given label to use the new set of label values
31845480ffeSMatthew G. Knepley 
31945480ffeSMatthew G. Knepley   Not Collective
32045480ffeSMatthew G. Knepley 
32145480ffeSMatthew G. Knepley   Input Parameters:
32245480ffeSMatthew G. Knepley + wf     - The original PetscWeakForm
32345480ffeSMatthew G. Knepley . label  - The label to change keys for
32445480ffeSMatthew G. Knepley . Nv     - The number of new label values
32545480ffeSMatthew G. Knepley - values - The set of new values to relabel keys with
32645480ffeSMatthew G. Knepley 
32745480ffeSMatthew G. Knepley   Note: This is used internally when boundary label values are specified from the command line.
32845480ffeSMatthew G. Knepley 
32945480ffeSMatthew G. Knepley   Level: intermediate
33045480ffeSMatthew G. Knepley 
33145480ffeSMatthew G. Knepley .seealso: PetscWeakFormCreate(), PetscWeakFormDestroy()
33245480ffeSMatthew G. Knepley @*/
33345480ffeSMatthew G. Knepley PetscErrorCode PetscWeakFormRewriteKeys(PetscWeakForm wf, DMLabel label, PetscInt Nv, const PetscInt values[])
33445480ffeSMatthew G. Knepley {
335*06ad1575SMatthew G. Knepley   PetscInt       f;
33645480ffeSMatthew G. Knepley   PetscErrorCode ierr;
33745480ffeSMatthew G. Knepley 
33845480ffeSMatthew G. Knepley   PetscFunctionBegin;
339*06ad1575SMatthew G. Knepley   for (f = 0; f < PETSC_NUM_WF; ++f) {ierr = PetscWeakFormRewriteKeys_Internal(wf, wf->form[f], label, Nv, values);CHKERRQ(ierr);}
34045480ffeSMatthew G. Knepley   PetscFunctionReturn(0);
34145480ffeSMatthew G. Knepley }
34245480ffeSMatthew G. Knepley 
343*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormClearIndex(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part, PetscWeakFormKind kind, PetscInt ind)
344*06ad1575SMatthew G. Knepley {
345*06ad1575SMatthew G. Knepley   PetscErrorCode ierr;
346*06ad1575SMatthew G. Knepley 
347*06ad1575SMatthew G. Knepley   PetscFunctionBegin;
348*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormClearIndexFunction_Private(wf, wf->form[kind], label, val, f, part, ind);CHKERRQ(ierr);
349*06ad1575SMatthew G. Knepley   PetscFunctionReturn(0);
350*06ad1575SMatthew G. Knepley }
351*06ad1575SMatthew G. Knepley 
352*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormGetObjective(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part, PetscInt *n,
3536528b96dSMatthew G. Knepley                                          void (***obj)(PetscInt, PetscInt, PetscInt,
3546528b96dSMatthew G. Knepley                                                        const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
3556528b96dSMatthew G. Knepley                                                        const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
3566528b96dSMatthew G. Knepley                                                        PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
3576528b96dSMatthew G. Knepley {
3586528b96dSMatthew G. Knepley   PetscErrorCode ierr;
3596528b96dSMatthew G. Knepley 
3606528b96dSMatthew G. Knepley   PetscFunctionBegin;
361*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_OBJECTIVE], label, val, f, part, n, (void (***)(void)) obj);CHKERRQ(ierr);
3626528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
3636528b96dSMatthew G. Knepley }
3646528b96dSMatthew G. Knepley 
365*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormSetObjective(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part, PetscInt n,
3666528b96dSMatthew G. Knepley                                          void (**obj)(PetscInt, PetscInt, PetscInt,
3676528b96dSMatthew G. Knepley                                                       const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const  PetscScalar[],
3686528b96dSMatthew G. Knepley                                                       const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
3696528b96dSMatthew G. Knepley                                                       PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
3706528b96dSMatthew G. Knepley {
3716528b96dSMatthew G. Knepley   PetscErrorCode ierr;
3726528b96dSMatthew G. Knepley 
3736528b96dSMatthew G. Knepley   PetscFunctionBegin;
374*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_OBJECTIVE], label, val, f, part, n, (void (**)(void)) obj);CHKERRQ(ierr);
3756528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
3766528b96dSMatthew G. Knepley }
3776528b96dSMatthew G. Knepley 
378*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormAddObjective(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part,
3796528b96dSMatthew G. Knepley                                          void (*obj)(PetscInt, PetscInt, PetscInt,
3806528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
3816528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
3826528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
3836528b96dSMatthew G. Knepley {
3846528b96dSMatthew G. Knepley   PetscErrorCode ierr;
3856528b96dSMatthew G. Knepley 
3866528b96dSMatthew G. Knepley   PetscFunctionBegin;
387*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_OBJECTIVE], label, val, f, part, (void (*)(void)) obj);CHKERRQ(ierr);
3886528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
3896528b96dSMatthew G. Knepley }
3906528b96dSMatthew G. Knepley 
391*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormGetIndexObjective(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part, PetscInt ind,
3926528b96dSMatthew G. Knepley                                               void (**obj)(PetscInt, PetscInt, PetscInt,
3936528b96dSMatthew G. Knepley                                                            const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
3946528b96dSMatthew G. Knepley                                                            const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
3956528b96dSMatthew G. Knepley                                                            PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
3966528b96dSMatthew G. Knepley {
3976528b96dSMatthew G. Knepley   PetscErrorCode ierr;
3986528b96dSMatthew G. Knepley 
3996528b96dSMatthew G. Knepley   PetscFunctionBegin;
400*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormGetIndexFunction_Private(wf, wf->form[PETSC_WF_OBJECTIVE], label, val, f, part, ind, (void (**)(void)) obj);CHKERRQ(ierr);
4016528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
4026528b96dSMatthew G. Knepley }
4036528b96dSMatthew G. Knepley 
404*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormSetIndexObjective(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part, PetscInt ind,
4056528b96dSMatthew G. Knepley                                               void (*obj)(PetscInt, PetscInt, PetscInt,
4066528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4076528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4086528b96dSMatthew G. Knepley                                                           PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
4096528b96dSMatthew G. Knepley {
4106528b96dSMatthew G. Knepley   PetscErrorCode ierr;
4116528b96dSMatthew G. Knepley 
4126528b96dSMatthew G. Knepley   PetscFunctionBegin;
413*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_OBJECTIVE], label, val, f, part, ind, (void (*)(void)) obj);CHKERRQ(ierr);
4146528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
4156528b96dSMatthew G. Knepley }
4166528b96dSMatthew G. Knepley 
417*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormGetResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part,
4186528b96dSMatthew G. Knepley                                         PetscInt *n0,
4196528b96dSMatthew G. Knepley                                         void (***f0)(PetscInt, PetscInt, PetscInt,
4206528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4216528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4226528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
4236528b96dSMatthew G. Knepley                                         PetscInt *n1,
4246528b96dSMatthew G. Knepley                                         void (***f1)(PetscInt, PetscInt, PetscInt,
4256528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4266528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4276528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
4286528b96dSMatthew G. Knepley {
4296528b96dSMatthew G. Knepley   PetscErrorCode ierr;
4306528b96dSMatthew G. Knepley 
4316528b96dSMatthew G. Knepley   PetscFunctionBegin;
432*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_F0], label, val, f, part, n0, (void (***)(void)) f0);CHKERRQ(ierr);
433*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_F1], label, val, f, part, n1, (void (***)(void)) f1);CHKERRQ(ierr);
4346528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
4356528b96dSMatthew G. Knepley }
4366528b96dSMatthew G. Knepley 
437*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormAddResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part,
4386528b96dSMatthew G. Knepley                                         void (*f0)(PetscInt, PetscInt, PetscInt,
4396528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4406528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4416528b96dSMatthew G. Knepley                                                    PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
4426528b96dSMatthew G. Knepley                                         void (*f1)(PetscInt, PetscInt, PetscInt,
4436528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4446528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4456528b96dSMatthew G. Knepley                                                    PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
4466528b96dSMatthew G. Knepley {
4476528b96dSMatthew G. Knepley   PetscErrorCode ierr;
4486528b96dSMatthew G. Knepley 
4496528b96dSMatthew G. Knepley   PetscFunctionBegin;
450*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_F0], label, val, f, part, (void (*)(void)) f0);CHKERRQ(ierr);
451*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_F1], label, val, f, part, (void (*)(void)) f1);CHKERRQ(ierr);
4526528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
4536528b96dSMatthew G. Knepley }
4546528b96dSMatthew G. Knepley 
455*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormSetResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part,
4566528b96dSMatthew G. Knepley                                         PetscInt n0,
4576528b96dSMatthew G. Knepley                                         void (**f0)(PetscInt, PetscInt, PetscInt,
4586528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4596528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4606528b96dSMatthew G. Knepley                                                    PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
4616528b96dSMatthew G. Knepley                                         PetscInt n1,
4626528b96dSMatthew G. Knepley                                         void (**f1)(PetscInt, PetscInt, PetscInt,
4636528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4646528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4656528b96dSMatthew G. Knepley                                                    PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
4666528b96dSMatthew G. Knepley {
4676528b96dSMatthew G. Knepley   PetscErrorCode ierr;
4686528b96dSMatthew G. Knepley 
4696528b96dSMatthew G. Knepley   PetscFunctionBegin;
470*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_F0], label, val, f, part, n0, (void (**)(void)) f0);CHKERRQ(ierr);
471*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_F1], label, val, f, part, n1, (void (**)(void)) f1);CHKERRQ(ierr);
4726528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
4736528b96dSMatthew G. Knepley }
4746528b96dSMatthew G. Knepley 
475*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormSetIndexResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part,
4766528b96dSMatthew G. Knepley                                         PetscInt i0,
4776528b96dSMatthew G. Knepley                                         void (*f0)(PetscInt, PetscInt, PetscInt,
4786528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4796528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4806528b96dSMatthew G. Knepley                                                    PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
4816528b96dSMatthew G. Knepley                                         PetscInt i1,
4826528b96dSMatthew G. Knepley                                         void (*f1)(PetscInt, PetscInt, PetscInt,
4836528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4846528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4856528b96dSMatthew G. Knepley                                                    PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
4866528b96dSMatthew G. Knepley {
4876528b96dSMatthew G. Knepley   PetscErrorCode ierr;
4886528b96dSMatthew G. Knepley 
4896528b96dSMatthew G. Knepley   PetscFunctionBegin;
490*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_F0], label, val, f, part, i0, (void (*)(void)) f0);CHKERRQ(ierr);
491*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_F1], label, val, f, part, i1, (void (*)(void)) f1);CHKERRQ(ierr);
4926528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
4936528b96dSMatthew G. Knepley }
4946528b96dSMatthew G. Knepley 
495*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormGetBdResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part,
4966528b96dSMatthew G. Knepley                                           PetscInt *n0,
4976528b96dSMatthew G. Knepley                                         void (***f0)(PetscInt, PetscInt, PetscInt,
4986528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
4996528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5006528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
5016528b96dSMatthew G. Knepley                                         PetscInt *n1,
5026528b96dSMatthew G. Knepley                                         void (***f1)(PetscInt, PetscInt, PetscInt,
5036528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5046528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5056528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
5066528b96dSMatthew G. Knepley {
5076528b96dSMatthew G. Knepley   PetscErrorCode ierr;
5086528b96dSMatthew G. Knepley 
5096528b96dSMatthew G. Knepley   PetscFunctionBegin;
510*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_BDF0], label, val, f, part, n0, (void (***)(void)) f0);CHKERRQ(ierr);
511*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_BDF1], label, val, f, part, n1, (void (***)(void)) f1);CHKERRQ(ierr);
5126528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
5136528b96dSMatthew G. Knepley }
5146528b96dSMatthew G. Knepley 
515*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormAddBdResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part,
5166528b96dSMatthew G. Knepley                                           void (*f0)(PetscInt, PetscInt, PetscInt,
5176528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5186528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5196528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
5206528b96dSMatthew G. Knepley                                           void (*f1)(PetscInt, PetscInt, PetscInt,
5216528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5226528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5236528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
5246528b96dSMatthew G. Knepley {
5256528b96dSMatthew G. Knepley   PetscErrorCode ierr;
5266528b96dSMatthew G. Knepley 
5276528b96dSMatthew G. Knepley   PetscFunctionBegin;
528*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_BDF0], label, val, f, part, (void (*)(void)) f0);CHKERRQ(ierr);
529*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_BDF1], label, val, f, part, (void (*)(void)) f1);CHKERRQ(ierr);
5306528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
5316528b96dSMatthew G. Knepley }
5326528b96dSMatthew G. Knepley 
533*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormSetBdResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part,
5346528b96dSMatthew G. Knepley                                           PetscInt n0,
5356528b96dSMatthew G. Knepley                                           void (**f0)(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, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
5396528b96dSMatthew G. Knepley                                           PetscInt n1,
5406528b96dSMatthew G. Knepley                                           void (**f1)(PetscInt, PetscInt, PetscInt,
5416528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5426528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5436528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
5446528b96dSMatthew G. Knepley {
5456528b96dSMatthew G. Knepley   PetscErrorCode ierr;
5466528b96dSMatthew G. Knepley 
5476528b96dSMatthew G. Knepley   PetscFunctionBegin;
548*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_BDF0], label, val, f, part, n0, (void (**)(void)) f0);CHKERRQ(ierr);
549*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_BDF1], label, val, f, part, n1, (void (**)(void)) f1);CHKERRQ(ierr);
5506528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
5516528b96dSMatthew G. Knepley }
5526528b96dSMatthew G. Knepley 
553*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormSetIndexBdResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part,
5546528b96dSMatthew G. Knepley                                           PetscInt i0,
5556528b96dSMatthew G. Knepley                                           void (*f0)(PetscInt, PetscInt, PetscInt,
5566528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5576528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5586528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
5596528b96dSMatthew G. Knepley                                           PetscInt i1,
5606528b96dSMatthew G. Knepley                                           void (*f1)(PetscInt, PetscInt, PetscInt,
5616528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5626528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5636528b96dSMatthew G. Knepley                                                      PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
5646528b96dSMatthew G. Knepley {
5656528b96dSMatthew G. Knepley   PetscErrorCode ierr;
5666528b96dSMatthew G. Knepley 
5676528b96dSMatthew G. Knepley   PetscFunctionBegin;
568*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_BDF0], label, val, f, part, i0, (void (*)(void)) f0);CHKERRQ(ierr);
569*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_BDF1], label, val, f, part, i1, (void (*)(void)) f1);CHKERRQ(ierr);
5706528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
5716528b96dSMatthew G. Knepley }
5726528b96dSMatthew G. Knepley 
5736528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormHasJacobian(PetscWeakForm wf, PetscBool *hasJac)
5746528b96dSMatthew G. Knepley {
5756528b96dSMatthew G. Knepley   PetscInt       n0, n1, n2, n3;
5766528b96dSMatthew G. Knepley   PetscErrorCode ierr;
5776528b96dSMatthew G. Knepley 
5786528b96dSMatthew G. Knepley   PetscFunctionBegin;
5796528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
5806528b96dSMatthew G. Knepley   PetscValidBoolPointer(hasJac, 2);
581*06ad1575SMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->form[PETSC_WF_G0], &n0);CHKERRQ(ierr);
582*06ad1575SMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->form[PETSC_WF_G1], &n1);CHKERRQ(ierr);
583*06ad1575SMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->form[PETSC_WF_G2], &n2);CHKERRQ(ierr);
584*06ad1575SMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->form[PETSC_WF_G3], &n3);CHKERRQ(ierr);
5856528b96dSMatthew G. Knepley   *hasJac = n0+n1+n2+n3 ? PETSC_TRUE : PETSC_FALSE;
5866528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
5876528b96dSMatthew G. Knepley }
5886528b96dSMatthew G. Knepley 
589*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormGetJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part,
5906528b96dSMatthew G. Knepley                                         PetscInt *n0,
5916528b96dSMatthew G. Knepley                                         void (***g0)(PetscInt, PetscInt, PetscInt,
5926528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5936528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5946528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
5956528b96dSMatthew G. Knepley                                         PetscInt *n1,
5966528b96dSMatthew G. Knepley                                         void (***g1)(PetscInt, PetscInt, PetscInt,
5976528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5986528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
5996528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
6006528b96dSMatthew G. Knepley                                         PetscInt *n2,
6016528b96dSMatthew G. Knepley                                         void (***g2)(PetscInt, PetscInt, PetscInt,
6026528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6036528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6046528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
6056528b96dSMatthew G. Knepley                                         PetscInt *n3,
6066528b96dSMatthew G. Knepley                                         void (***g3)(PetscInt, PetscInt, PetscInt,
6076528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6086528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6096528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
6106528b96dSMatthew G. Knepley {
6116528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
6126528b96dSMatthew G. Knepley   PetscErrorCode ierr;
6136528b96dSMatthew G. Knepley 
6146528b96dSMatthew G. Knepley   PetscFunctionBegin;
615*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_G0], label, val, find, part, n0, (void (***)(void)) g0);CHKERRQ(ierr);
616*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_G1], label, val, find, part, n1, (void (***)(void)) g1);CHKERRQ(ierr);
617*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_G2], label, val, find, part, n2, (void (***)(void)) g2);CHKERRQ(ierr);
618*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_G3], label, val, find, part, n3, (void (***)(void)) g3);CHKERRQ(ierr);
6196528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
6206528b96dSMatthew G. Knepley }
6216528b96dSMatthew G. Knepley 
622*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormAddJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part,
6236528b96dSMatthew G. Knepley                                         void (*g0)(PetscInt, PetscInt, PetscInt,
6246528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6256528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6266528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
6276528b96dSMatthew G. Knepley                                         void (*g1)(PetscInt, PetscInt, PetscInt,
6286528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6296528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6306528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
6316528b96dSMatthew G. Knepley                                         void (*g2)(PetscInt, PetscInt, PetscInt,
6326528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6336528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6346528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
6356528b96dSMatthew G. Knepley                                         void (*g3)(PetscInt, PetscInt, PetscInt,
6366528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6376528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6386528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
6396528b96dSMatthew G. Knepley {
6406528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
6416528b96dSMatthew G. Knepley   PetscErrorCode ierr;
6426528b96dSMatthew G. Knepley 
6436528b96dSMatthew G. Knepley   PetscFunctionBegin;
644*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_G0], label, val, find, part, (void (*)(void)) g0);CHKERRQ(ierr);
645*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_G1], label, val, find, part, (void (*)(void)) g1);CHKERRQ(ierr);
646*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_G2], label, val, find, part, (void (*)(void)) g2);CHKERRQ(ierr);
647*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_G3], label, val, find, part, (void (*)(void)) g3);CHKERRQ(ierr);
6486528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
6496528b96dSMatthew G. Knepley }
6506528b96dSMatthew G. Knepley 
651*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormSetJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part,
6526528b96dSMatthew G. Knepley                                         PetscInt n0,
6536528b96dSMatthew G. Knepley                                         void (**g0)(PetscInt, PetscInt, PetscInt,
6546528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6556528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6566528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
6576528b96dSMatthew G. Knepley                                         PetscInt n1,
6586528b96dSMatthew G. Knepley                                         void (**g1)(PetscInt, PetscInt, PetscInt,
6596528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6606528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6616528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
6626528b96dSMatthew G. Knepley                                         PetscInt n2,
6636528b96dSMatthew G. Knepley                                         void (**g2)(PetscInt, PetscInt, PetscInt,
6646528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6656528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6666528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
6676528b96dSMatthew G. Knepley                                         PetscInt n3,
6686528b96dSMatthew G. Knepley                                         void (**g3)(PetscInt, PetscInt, PetscInt,
6696528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6706528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6716528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
6726528b96dSMatthew G. Knepley {
6736528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
6746528b96dSMatthew G. Knepley   PetscErrorCode ierr;
6756528b96dSMatthew G. Knepley 
6766528b96dSMatthew G. Knepley   PetscFunctionBegin;
677*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_G0], label, val, find, part, n0, (void (**)(void)) g0);CHKERRQ(ierr);
678*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_G1], label, val, find, part, n1, (void (**)(void)) g1);CHKERRQ(ierr);
679*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_G2], label, val, find, part, n2, (void (**)(void)) g2);CHKERRQ(ierr);
680*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_G3], label, val, find, part, n3, (void (**)(void)) g3);CHKERRQ(ierr);
6816528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
6826528b96dSMatthew G. Knepley }
6836528b96dSMatthew G. Knepley 
684*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormSetIndexJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part,
6856528b96dSMatthew G. Knepley                                         PetscInt i0,
6866528b96dSMatthew G. Knepley                                         void (*g0)(PetscInt, PetscInt, PetscInt,
6876528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6886528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6896528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
6906528b96dSMatthew G. Knepley                                         PetscInt i1,
6916528b96dSMatthew G. Knepley                                         void (*g1)(PetscInt, PetscInt, PetscInt,
6926528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6936528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6946528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
6956528b96dSMatthew G. Knepley                                         PetscInt i2,
6966528b96dSMatthew G. Knepley                                         void (*g2)(PetscInt, PetscInt, PetscInt,
6976528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6986528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
6996528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
7006528b96dSMatthew G. Knepley                                         PetscInt i3,
7016528b96dSMatthew G. Knepley                                         void (*g3)(PetscInt, PetscInt, PetscInt,
7026528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7036528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7046528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
7056528b96dSMatthew G. Knepley {
7066528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
7076528b96dSMatthew G. Knepley   PetscErrorCode ierr;
7086528b96dSMatthew G. Knepley 
7096528b96dSMatthew G. Knepley   PetscFunctionBegin;
710*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_G0], label, val, find, part, i0, (void (*)(void)) g0);CHKERRQ(ierr);
711*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_G1], label, val, find, part, i1, (void (*)(void)) g1);CHKERRQ(ierr);
712*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_G2], label, val, find, part, i2, (void (*)(void)) g2);CHKERRQ(ierr);
713*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_G3], label, val, find, part, i3, (void (*)(void)) g3);CHKERRQ(ierr);
7146528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
7156528b96dSMatthew G. Knepley }
7166528b96dSMatthew G. Knepley 
7176528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormHasJacobianPreconditioner(PetscWeakForm wf, PetscBool *hasJacPre)
7186528b96dSMatthew G. Knepley {
7196528b96dSMatthew G. Knepley   PetscInt       n0, n1, n2, n3;
7206528b96dSMatthew G. Knepley   PetscErrorCode ierr;
7216528b96dSMatthew G. Knepley 
7226528b96dSMatthew G. Knepley   PetscFunctionBegin;
7236528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
7246528b96dSMatthew G. Knepley   PetscValidBoolPointer(hasJacPre, 2);
725*06ad1575SMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->form[PETSC_WF_GP0], &n0);CHKERRQ(ierr);
726*06ad1575SMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->form[PETSC_WF_GP1], &n1);CHKERRQ(ierr);
727*06ad1575SMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->form[PETSC_WF_GP2], &n2);CHKERRQ(ierr);
728*06ad1575SMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->form[PETSC_WF_GP3], &n3);CHKERRQ(ierr);
7296528b96dSMatthew G. Knepley   *hasJacPre = n0+n1+n2+n3 ? PETSC_TRUE : PETSC_FALSE;
7306528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
7316528b96dSMatthew G. Knepley }
7326528b96dSMatthew G. Knepley 
733*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormGetJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part,
7346528b96dSMatthew G. Knepley                                                       PetscInt *n0,
7356528b96dSMatthew G. Knepley                                                       void (***g0)(PetscInt, PetscInt, PetscInt,
7366528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7376528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7386528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
7396528b96dSMatthew G. Knepley                                                       PetscInt *n1,
7406528b96dSMatthew G. Knepley                                                       void (***g1)(PetscInt, PetscInt, PetscInt,
7416528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7426528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7436528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
7446528b96dSMatthew G. Knepley                                                       PetscInt *n2,
7456528b96dSMatthew G. Knepley                                                       void (***g2)(PetscInt, PetscInt, PetscInt,
7466528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7476528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7486528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
7496528b96dSMatthew G. Knepley                                                       PetscInt *n3,
7506528b96dSMatthew G. Knepley                                                       void (***g3)(PetscInt, PetscInt, PetscInt,
7516528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7526528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7536528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
7546528b96dSMatthew G. Knepley {
7556528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
7566528b96dSMatthew G. Knepley   PetscErrorCode ierr;
7576528b96dSMatthew G. Knepley 
7586528b96dSMatthew G. Knepley   PetscFunctionBegin;
759*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_GP0], label, val, find, part, n0, (void (***)(void)) g0);CHKERRQ(ierr);
760*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_GP1], label, val, find, part, n1, (void (***)(void)) g1);CHKERRQ(ierr);
761*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_GP2], label, val, find, part, n2, (void (***)(void)) g2);CHKERRQ(ierr);
762*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_GP3], label, val, find, part, n3, (void (***)(void)) g3);CHKERRQ(ierr);
7636528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
7646528b96dSMatthew G. Knepley }
7656528b96dSMatthew G. Knepley 
766*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormAddJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part,
7676528b96dSMatthew G. Knepley                                         void (*g0)(PetscInt, PetscInt, PetscInt,
7686528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7696528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7706528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
7716528b96dSMatthew G. Knepley                                         void (*g1)(PetscInt, PetscInt, PetscInt,
7726528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7736528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7746528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
7756528b96dSMatthew G. Knepley                                         void (*g2)(PetscInt, PetscInt, PetscInt,
7766528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7776528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7786528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
7796528b96dSMatthew G. Knepley                                         void (*g3)(PetscInt, PetscInt, PetscInt,
7806528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7816528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7826528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
7836528b96dSMatthew G. Knepley {
7846528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
7856528b96dSMatthew G. Knepley   PetscErrorCode ierr;
7866528b96dSMatthew G. Knepley 
7876528b96dSMatthew G. Knepley   PetscFunctionBegin;
788*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_GP0], label, val, find, part, (void (*)(void)) g0);CHKERRQ(ierr);
789*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_GP1], label, val, find, part, (void (*)(void)) g1);CHKERRQ(ierr);
790*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_GP2], label, val, find, part, (void (*)(void)) g2);CHKERRQ(ierr);
791*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_GP3], label, val, find, part, (void (*)(void)) g3);CHKERRQ(ierr);
7926528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
7936528b96dSMatthew G. Knepley }
7946528b96dSMatthew G. Knepley 
795*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormSetJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part,
7966528b96dSMatthew G. Knepley                                                       PetscInt n0,
7976528b96dSMatthew G. Knepley                                                       void (**g0)(PetscInt, PetscInt, PetscInt,
7986528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
7996528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8006528b96dSMatthew G. Knepley                                                                  PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
8016528b96dSMatthew G. Knepley                                                       PetscInt n1,
8026528b96dSMatthew G. Knepley                                                       void (**g1)(PetscInt, PetscInt, PetscInt,
8036528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8046528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8056528b96dSMatthew G. Knepley                                                                  PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
8066528b96dSMatthew G. Knepley                                                       PetscInt n2,
8076528b96dSMatthew G. Knepley                                                       void (**g2)(PetscInt, PetscInt, PetscInt,
8086528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8096528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8106528b96dSMatthew G. Knepley                                                                  PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
8116528b96dSMatthew G. Knepley                                                       PetscInt n3,
8126528b96dSMatthew G. Knepley                                                       void (**g3)(PetscInt, PetscInt, PetscInt,
8136528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8146528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8156528b96dSMatthew G. Knepley                                                                  PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
8166528b96dSMatthew G. Knepley {
8176528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
8186528b96dSMatthew G. Knepley   PetscErrorCode ierr;
8196528b96dSMatthew G. Knepley 
8206528b96dSMatthew G. Knepley   PetscFunctionBegin;
821*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_GP0], label, val, find, part, n0, (void (**)(void)) g0);CHKERRQ(ierr);
822*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_GP1], label, val, find, part, n1, (void (**)(void)) g1);CHKERRQ(ierr);
823*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_GP2], label, val, find, part, n2, (void (**)(void)) g2);CHKERRQ(ierr);
824*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_GP3], label, val, find, part, n3, (void (**)(void)) g3);CHKERRQ(ierr);
8256528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
8266528b96dSMatthew G. Knepley }
8276528b96dSMatthew G. Knepley 
828*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormSetIndexJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part,
8296528b96dSMatthew G. Knepley                                                       PetscInt i0,
8306528b96dSMatthew G. Knepley                                                       void (*g0)(PetscInt, PetscInt, PetscInt,
8316528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8326528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8336528b96dSMatthew G. Knepley                                                                  PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
8346528b96dSMatthew G. Knepley                                                       PetscInt i1,
8356528b96dSMatthew G. Knepley                                                       void (*g1)(PetscInt, PetscInt, PetscInt,
8366528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8376528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8386528b96dSMatthew G. Knepley                                                                  PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
8396528b96dSMatthew G. Knepley                                                       PetscInt i2,
8406528b96dSMatthew G. Knepley                                                       void (*g2)(PetscInt, PetscInt, PetscInt,
8416528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8426528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8436528b96dSMatthew G. Knepley                                                                  PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
8446528b96dSMatthew G. Knepley                                                       PetscInt i3,
8456528b96dSMatthew G. Knepley                                                       void (*g3)(PetscInt, PetscInt, PetscInt,
8466528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8476528b96dSMatthew G. Knepley                                                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8486528b96dSMatthew G. Knepley                                                                  PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
8496528b96dSMatthew G. Knepley {
8506528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
8516528b96dSMatthew G. Knepley   PetscErrorCode ierr;
8526528b96dSMatthew G. Knepley 
8536528b96dSMatthew G. Knepley   PetscFunctionBegin;
854*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_GP0], label, val, find, part, i0, (void (*)(void)) g0);CHKERRQ(ierr);
855*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_GP1], label, val, find, part, i1, (void (*)(void)) g1);CHKERRQ(ierr);
856*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_GP2], label, val, find, part, i2, (void (*)(void)) g2);CHKERRQ(ierr);
857*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_GP3], label, val, find, part, i3, (void (*)(void)) g3);CHKERRQ(ierr);
8586528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
8596528b96dSMatthew G. Knepley }
8606528b96dSMatthew G. Knepley 
8616528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormHasBdJacobian(PetscWeakForm wf, PetscBool *hasJac)
8626528b96dSMatthew G. Knepley {
8636528b96dSMatthew G. Knepley   PetscInt       n0, n1, n2, n3;
8646528b96dSMatthew G. Knepley   PetscErrorCode ierr;
8656528b96dSMatthew G. Knepley 
8666528b96dSMatthew G. Knepley   PetscFunctionBegin;
8676528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
8686528b96dSMatthew G. Knepley   PetscValidBoolPointer(hasJac, 2);
869*06ad1575SMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->form[PETSC_WF_BDG0], &n0);CHKERRQ(ierr);
870*06ad1575SMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->form[PETSC_WF_BDG1], &n1);CHKERRQ(ierr);
871*06ad1575SMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->form[PETSC_WF_BDG2], &n2);CHKERRQ(ierr);
872*06ad1575SMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->form[PETSC_WF_BDG3], &n3);CHKERRQ(ierr);
8736528b96dSMatthew G. Knepley   *hasJac = n0+n1+n2+n3 ? PETSC_TRUE : PETSC_FALSE;
8746528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
8756528b96dSMatthew G. Knepley }
8766528b96dSMatthew G. Knepley 
877*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormGetBdJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part,
8786528b96dSMatthew G. Knepley                                           PetscInt *n0,
8796528b96dSMatthew G. Knepley                                           void (***g0)(PetscInt, PetscInt, PetscInt,
8806528b96dSMatthew G. Knepley                                                        const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8816528b96dSMatthew G. Knepley                                                        const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8826528b96dSMatthew G. Knepley                                                        PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
8836528b96dSMatthew G. Knepley                                           PetscInt *n1,
8846528b96dSMatthew G. Knepley                                           void (***g1)(PetscInt, PetscInt, PetscInt,
8856528b96dSMatthew G. Knepley                                                        const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8866528b96dSMatthew G. Knepley                                                        const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8876528b96dSMatthew G. Knepley                                                        PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
8886528b96dSMatthew G. Knepley                                           PetscInt *n2,
8896528b96dSMatthew G. Knepley                                           void (***g2)(PetscInt, PetscInt, PetscInt,
8906528b96dSMatthew G. Knepley                                                        const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8916528b96dSMatthew G. Knepley                                                        const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8926528b96dSMatthew G. Knepley                                                        PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
8936528b96dSMatthew G. Knepley                                           PetscInt *n3,
8946528b96dSMatthew G. Knepley                                           void (***g3)(PetscInt, PetscInt, PetscInt,
8956528b96dSMatthew G. Knepley                                                        const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8966528b96dSMatthew G. Knepley                                                        const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
8976528b96dSMatthew G. Knepley                                                        PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
8986528b96dSMatthew G. Knepley {
8996528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
9006528b96dSMatthew G. Knepley   PetscErrorCode ierr;
9016528b96dSMatthew G. Knepley 
9026528b96dSMatthew G. Knepley   PetscFunctionBegin;
903*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_BDG0], label, val, find, part, n0, (void (***)(void)) g0);CHKERRQ(ierr);
904*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_BDG1], label, val, find, part, n1, (void (***)(void)) g1);CHKERRQ(ierr);
905*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_BDG2], label, val, find, part, n2, (void (***)(void)) g2);CHKERRQ(ierr);
906*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_BDG3], label, val, find, part, n3, (void (***)(void)) g3);CHKERRQ(ierr);
9076528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
9086528b96dSMatthew G. Knepley }
9096528b96dSMatthew G. Knepley 
910*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormAddBdJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part,
9116528b96dSMatthew G. Knepley                                           void (*g0)(PetscInt, PetscInt, PetscInt,
9126528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9136528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9146528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
9156528b96dSMatthew G. Knepley                                           void (*g1)(PetscInt, PetscInt, PetscInt,
9166528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9176528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9186528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
9196528b96dSMatthew G. Knepley                                           void (*g2)(PetscInt, PetscInt, PetscInt,
9206528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9216528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9226528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
9236528b96dSMatthew G. Knepley                                           void (*g3)(PetscInt, PetscInt, PetscInt,
9246528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9256528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9266528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
9276528b96dSMatthew G. Knepley {
9286528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
9296528b96dSMatthew G. Knepley   PetscErrorCode ierr;
9306528b96dSMatthew G. Knepley 
9316528b96dSMatthew G. Knepley   PetscFunctionBegin;
932*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_BDG0], label, val, find, part, (void (*)(void)) g0);CHKERRQ(ierr);
933*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_BDG1], label, val, find, part, (void (*)(void)) g1);CHKERRQ(ierr);
934*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_BDG2], label, val, find, part, (void (*)(void)) g2);CHKERRQ(ierr);
935*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_BDG3], label, val, find, part, (void (*)(void)) g3);CHKERRQ(ierr);
9366528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
9376528b96dSMatthew G. Knepley }
9386528b96dSMatthew G. Knepley 
939*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormSetBdJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part,
9406528b96dSMatthew G. Knepley                                           PetscInt n0,
9416528b96dSMatthew G. Knepley                                           void (**g0)(PetscInt, PetscInt, PetscInt,
9426528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9436528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9446528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
9456528b96dSMatthew G. Knepley                                           PetscInt n1,
9466528b96dSMatthew G. Knepley                                           void (**g1)(PetscInt, PetscInt, PetscInt,
9476528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9486528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9496528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
9506528b96dSMatthew G. Knepley                                           PetscInt n2,
9516528b96dSMatthew G. Knepley                                           void (**g2)(PetscInt, PetscInt, PetscInt,
9526528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9536528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9546528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
9556528b96dSMatthew G. Knepley                                           PetscInt n3,
9566528b96dSMatthew G. Knepley                                           void (**g3)(PetscInt, PetscInt, PetscInt,
9576528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9586528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9596528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
9606528b96dSMatthew G. Knepley {
9616528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
9626528b96dSMatthew G. Knepley   PetscErrorCode ierr;
9636528b96dSMatthew G. Knepley 
9646528b96dSMatthew G. Knepley   PetscFunctionBegin;
965*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_BDG0], label, val, find, part, n0, (void (**)(void)) g0);CHKERRQ(ierr);
966*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_BDG1], label, val, find, part, n1, (void (**)(void)) g1);CHKERRQ(ierr);
967*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_BDG2], label, val, find, part, n2, (void (**)(void)) g2);CHKERRQ(ierr);
968*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_BDG3], label, val, find, part, n3, (void (**)(void)) g3);CHKERRQ(ierr);
9696528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
9706528b96dSMatthew G. Knepley }
9716528b96dSMatthew G. Knepley 
972*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormSetIndexBdJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part,
9736528b96dSMatthew G. Knepley                                           PetscInt i0,
9746528b96dSMatthew G. Knepley                                           void (*g0)(PetscInt, PetscInt, PetscInt,
9756528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9766528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9776528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
9786528b96dSMatthew G. Knepley                                           PetscInt i1,
9796528b96dSMatthew G. Knepley                                           void (*g1)(PetscInt, PetscInt, PetscInt,
9806528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9816528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9826528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
9836528b96dSMatthew G. Knepley                                           PetscInt i2,
9846528b96dSMatthew G. Knepley                                           void (*g2)(PetscInt, PetscInt, PetscInt,
9856528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9866528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9876528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
9886528b96dSMatthew G. Knepley                                           PetscInt i3,
9896528b96dSMatthew G. Knepley                                           void (*g3)(PetscInt, PetscInt, PetscInt,
9906528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9916528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
9926528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
9936528b96dSMatthew G. Knepley {
9946528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
9956528b96dSMatthew G. Knepley   PetscErrorCode ierr;
9966528b96dSMatthew G. Knepley 
9976528b96dSMatthew G. Knepley   PetscFunctionBegin;
998*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_BDG0], label, val, find, part, i0, (void (*)(void)) g0);CHKERRQ(ierr);
999*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_BDG1], label, val, find, part, i1, (void (*)(void)) g1);CHKERRQ(ierr);
1000*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_BDG2], label, val, find, part, i2, (void (*)(void)) g2);CHKERRQ(ierr);
1001*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_BDG3], label, val, find, part, i3, (void (*)(void)) g3);CHKERRQ(ierr);
10026528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
10036528b96dSMatthew G. Knepley }
10046528b96dSMatthew G. Knepley 
10056528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormHasBdJacobianPreconditioner(PetscWeakForm wf, PetscBool *hasJacPre)
10066528b96dSMatthew G. Knepley {
10076528b96dSMatthew G. Knepley   PetscInt       n0, n1, n2, n3;
10086528b96dSMatthew G. Knepley   PetscErrorCode ierr;
10096528b96dSMatthew G. Knepley 
10106528b96dSMatthew G. Knepley   PetscFunctionBegin;
10116528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
10126528b96dSMatthew G. Knepley   PetscValidBoolPointer(hasJacPre, 2);
1013*06ad1575SMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->form[PETSC_WF_BDGP0], &n0);CHKERRQ(ierr);
1014*06ad1575SMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->form[PETSC_WF_BDGP1], &n1);CHKERRQ(ierr);
1015*06ad1575SMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->form[PETSC_WF_BDGP2], &n2);CHKERRQ(ierr);
1016*06ad1575SMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->form[PETSC_WF_BDGP3], &n3);CHKERRQ(ierr);
10176528b96dSMatthew G. Knepley   *hasJacPre = n0+n1+n2+n3 ? PETSC_TRUE : PETSC_FALSE;
10186528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
10196528b96dSMatthew G. Knepley }
10206528b96dSMatthew G. Knepley 
1021*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormGetBdJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part,
10226528b96dSMatthew G. Knepley                                                         PetscInt *n0,
10236528b96dSMatthew G. Knepley                                                         void (***g0)(PetscInt, PetscInt, PetscInt,
10246528b96dSMatthew G. Knepley                                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10256528b96dSMatthew G. Knepley                                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10266528b96dSMatthew G. Knepley                                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
10276528b96dSMatthew G. Knepley                                                         PetscInt *n1,
10286528b96dSMatthew G. Knepley                                                         void (***g1)(PetscInt, PetscInt, PetscInt,
10296528b96dSMatthew G. Knepley                                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10306528b96dSMatthew G. Knepley                                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10316528b96dSMatthew G. Knepley                                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
10326528b96dSMatthew G. Knepley                                                         PetscInt *n2,
10336528b96dSMatthew G. Knepley                                                         void (***g2)(PetscInt, PetscInt, PetscInt,
10346528b96dSMatthew G. Knepley                                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10356528b96dSMatthew G. Knepley                                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10366528b96dSMatthew G. Knepley                                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
10376528b96dSMatthew G. Knepley                                                         PetscInt *n3,
10386528b96dSMatthew G. Knepley                                                         void (***g3)(PetscInt, PetscInt, PetscInt,
10396528b96dSMatthew G. Knepley                                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10406528b96dSMatthew G. Knepley                                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10416528b96dSMatthew G. Knepley                                                                      PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
10426528b96dSMatthew G. Knepley {
10436528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
10446528b96dSMatthew G. Knepley   PetscErrorCode ierr;
10456528b96dSMatthew G. Knepley 
10466528b96dSMatthew G. Knepley   PetscFunctionBegin;
1047*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_BDGP0], label, val, find, part, n0, (void (***)(void)) g0);CHKERRQ(ierr);
1048*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_BDGP1], label, val, find, part, n1, (void (***)(void)) g1);CHKERRQ(ierr);
1049*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_BDGP2], label, val, find, part, n2, (void (***)(void)) g2);CHKERRQ(ierr);
1050*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_BDGP3], label, val, find, part, n3, (void (***)(void)) g3);CHKERRQ(ierr);
10516528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
10526528b96dSMatthew G. Knepley }
10536528b96dSMatthew G. Knepley 
1054*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormAddBdJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part,
10556528b96dSMatthew G. Knepley                                                         void (*g0)(PetscInt, PetscInt, PetscInt,
10566528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10576528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10586528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
10596528b96dSMatthew G. Knepley                                                         void (*g1)(PetscInt, PetscInt, PetscInt,
10606528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10616528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10626528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
10636528b96dSMatthew G. Knepley                                                         void (*g2)(PetscInt, PetscInt, PetscInt,
10646528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10656528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10666528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
10676528b96dSMatthew G. Knepley                                                         void (*g3)(PetscInt, PetscInt, PetscInt,
10686528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10696528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10706528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
10716528b96dSMatthew G. Knepley {
10726528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
10736528b96dSMatthew G. Knepley   PetscErrorCode ierr;
10746528b96dSMatthew G. Knepley 
10756528b96dSMatthew G. Knepley   PetscFunctionBegin;
1076*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_BDGP0], label, val, find, part, (void (*)(void)) g0);CHKERRQ(ierr);
1077*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_BDGP1], label, val, find, part, (void (*)(void)) g1);CHKERRQ(ierr);
1078*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_BDGP2], label, val, find, part, (void (*)(void)) g2);CHKERRQ(ierr);
1079*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_BDGP3], label, val, find, part, (void (*)(void)) g3);CHKERRQ(ierr);
10806528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
10816528b96dSMatthew G. Knepley }
10826528b96dSMatthew G. Knepley 
1083*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormSetBdJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part,
10846528b96dSMatthew G. Knepley                                                         PetscInt n0,
10856528b96dSMatthew G. Knepley                                                         void (**g0)(PetscInt, PetscInt, PetscInt,
10866528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10876528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10886528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
10896528b96dSMatthew G. Knepley                                                         PetscInt n1,
10906528b96dSMatthew G. Knepley                                                         void (**g1)(PetscInt, PetscInt, PetscInt,
10916528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10926528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10936528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
10946528b96dSMatthew G. Knepley                                                         PetscInt n2,
10956528b96dSMatthew G. Knepley                                                         void (**g2)(PetscInt, PetscInt, PetscInt,
10966528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10976528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
10986528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
10996528b96dSMatthew G. Knepley                                                         PetscInt n3,
11006528b96dSMatthew G. Knepley                                                         void (**g3)(PetscInt, PetscInt, PetscInt,
11016528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11026528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11036528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
11046528b96dSMatthew G. Knepley {
11056528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
11066528b96dSMatthew G. Knepley   PetscErrorCode ierr;
11076528b96dSMatthew G. Knepley 
11086528b96dSMatthew G. Knepley   PetscFunctionBegin;
1109*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_BDGP0], label, val, find, part, n0, (void (**)(void)) g0);CHKERRQ(ierr);
1110*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_BDGP1], label, val, find, part, n1, (void (**)(void)) g1);CHKERRQ(ierr);
1111*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_BDGP2], label, val, find, part, n2, (void (**)(void)) g2);CHKERRQ(ierr);
1112*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_BDGP3], label, val, find, part, n3, (void (**)(void)) g3);CHKERRQ(ierr);
11136528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
11146528b96dSMatthew G. Knepley }
11156528b96dSMatthew G. Knepley 
1116*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormSetIndexBdJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part,
11176528b96dSMatthew G. Knepley                                                         PetscInt i0,
11186528b96dSMatthew G. Knepley                                                         void (*g0)(PetscInt, PetscInt, PetscInt,
11196528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11206528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11216528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
11226528b96dSMatthew G. Knepley                                                         PetscInt i1,
11236528b96dSMatthew G. Knepley                                                         void (*g1)(PetscInt, PetscInt, PetscInt,
11246528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11256528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11266528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
11276528b96dSMatthew G. Knepley                                                         PetscInt i2,
11286528b96dSMatthew G. Knepley                                                         void (*g2)(PetscInt, PetscInt, PetscInt,
11296528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11306528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11316528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
11326528b96dSMatthew G. Knepley                                                         PetscInt i3,
11336528b96dSMatthew G. Knepley                                                         void (*g3)(PetscInt, PetscInt, PetscInt,
11346528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11356528b96dSMatthew G. Knepley                                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11366528b96dSMatthew G. Knepley                                                                    PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
11376528b96dSMatthew G. Knepley {
11386528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
11396528b96dSMatthew G. Knepley   PetscErrorCode ierr;
11406528b96dSMatthew G. Knepley 
11416528b96dSMatthew G. Knepley   PetscFunctionBegin;
1142*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_BDGP0], label, val, find, part, i0, (void (*)(void)) g0);CHKERRQ(ierr);
1143*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_BDGP1], label, val, find, part, i1, (void (*)(void)) g1);CHKERRQ(ierr);
1144*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_BDGP2], label, val, find, part, i2, (void (*)(void)) g2);CHKERRQ(ierr);
1145*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_BDGP3], label, val, find, part, i3, (void (*)(void)) g3);CHKERRQ(ierr);
11466528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
11476528b96dSMatthew G. Knepley }
11486528b96dSMatthew G. Knepley 
11496528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormHasDynamicJacobian(PetscWeakForm wf, PetscBool *hasDynJac)
11506528b96dSMatthew G. Knepley {
11516528b96dSMatthew G. Knepley   PetscInt       n0, n1, n2, n3;
11526528b96dSMatthew G. Knepley   PetscErrorCode ierr;
11536528b96dSMatthew G. Knepley 
11546528b96dSMatthew G. Knepley   PetscFunctionBegin;
11556528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
11566528b96dSMatthew G. Knepley   PetscValidBoolPointer(hasDynJac, 2);
1157*06ad1575SMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->form[PETSC_WF_GT0], &n0);CHKERRQ(ierr);
1158*06ad1575SMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->form[PETSC_WF_GT1], &n1);CHKERRQ(ierr);
1159*06ad1575SMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->form[PETSC_WF_GT2], &n2);CHKERRQ(ierr);
1160*06ad1575SMatthew G. Knepley   ierr = PetscHMapFormGetSize(wf->form[PETSC_WF_GT3], &n3);CHKERRQ(ierr);
11616528b96dSMatthew G. Knepley   *hasDynJac = n0+n1+n2+n3 ? PETSC_TRUE : PETSC_FALSE;
11626528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
11636528b96dSMatthew G. Knepley }
11646528b96dSMatthew G. Knepley 
1165*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormGetDynamicJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part,
11666528b96dSMatthew G. Knepley                                         PetscInt *n0,
11676528b96dSMatthew G. Knepley                                         void (***g0)(PetscInt, PetscInt, PetscInt,
11686528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11696528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11706528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
11716528b96dSMatthew G. Knepley                                         PetscInt *n1,
11726528b96dSMatthew G. Knepley                                         void (***g1)(PetscInt, PetscInt, PetscInt,
11736528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11746528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11756528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
11766528b96dSMatthew G. Knepley                                         PetscInt *n2,
11776528b96dSMatthew G. Knepley                                         void (***g2)(PetscInt, PetscInt, PetscInt,
11786528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11796528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11806528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
11816528b96dSMatthew G. Knepley                                         PetscInt *n3,
11826528b96dSMatthew G. Knepley                                         void (***g3)(PetscInt, PetscInt, PetscInt,
11836528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11846528b96dSMatthew G. Knepley                                                      const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
11856528b96dSMatthew G. Knepley                                                      PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
11866528b96dSMatthew G. Knepley {
11876528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
11886528b96dSMatthew G. Knepley   PetscErrorCode ierr;
11896528b96dSMatthew G. Knepley 
11906528b96dSMatthew G. Knepley   PetscFunctionBegin;
1191*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_GT0], label, val, find, part, n0, (void (***)(void)) g0);CHKERRQ(ierr);
1192*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_GT1], label, val, find, part, n1, (void (***)(void)) g1);CHKERRQ(ierr);
1193*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_GT2], label, val, find, part, n2, (void (***)(void)) g2);CHKERRQ(ierr);
1194*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_GT3], label, val, find, part, n3, (void (***)(void)) g3);CHKERRQ(ierr);
11956528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
11966528b96dSMatthew G. Knepley }
11976528b96dSMatthew G. Knepley 
1198*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormAddDynamicJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part,
11996528b96dSMatthew G. Knepley                                         void (*g0)(PetscInt, PetscInt, PetscInt,
12006528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12016528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12026528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
12036528b96dSMatthew G. Knepley                                         void (*g1)(PetscInt, PetscInt, PetscInt,
12046528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12056528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12066528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
12076528b96dSMatthew G. Knepley                                         void (*g2)(PetscInt, PetscInt, PetscInt,
12086528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12096528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12106528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
12116528b96dSMatthew G. Knepley                                         void (*g3)(PetscInt, PetscInt, PetscInt,
12126528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12136528b96dSMatthew G. Knepley                                                    const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12146528b96dSMatthew G. Knepley                                                    PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
12156528b96dSMatthew G. Knepley {
12166528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
12176528b96dSMatthew G. Knepley   PetscErrorCode ierr;
12186528b96dSMatthew G. Knepley 
12196528b96dSMatthew G. Knepley   PetscFunctionBegin;
1220*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_GT0], label, val, find, part, (void (*)(void)) g0);CHKERRQ(ierr);
1221*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_GT1], label, val, find, part, (void (*)(void)) g1);CHKERRQ(ierr);
1222*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_GT2], label, val, find, part, (void (*)(void)) g2);CHKERRQ(ierr);
1223*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_GT3], label, val, find, part, (void (*)(void)) g3);CHKERRQ(ierr);
12246528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
12256528b96dSMatthew G. Knepley }
12266528b96dSMatthew G. Knepley 
1227*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormSetDynamicJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part,
12286528b96dSMatthew G. Knepley                                                PetscInt n0,
12296528b96dSMatthew G. Knepley                                                void (**g0)(PetscInt, PetscInt, PetscInt,
12306528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12316528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12326528b96dSMatthew G. Knepley                                                           PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
12336528b96dSMatthew G. Knepley                                                PetscInt n1,
12346528b96dSMatthew G. Knepley                                                void (**g1)(PetscInt, PetscInt, PetscInt,
12356528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12366528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12376528b96dSMatthew G. Knepley                                                           PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
12386528b96dSMatthew G. Knepley                                                PetscInt n2,
12396528b96dSMatthew G. Knepley                                                void (**g2)(PetscInt, PetscInt, PetscInt,
12406528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12416528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12426528b96dSMatthew G. Knepley                                                           PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
12436528b96dSMatthew G. Knepley                                                PetscInt n3,
12446528b96dSMatthew G. Knepley                                                void (**g3)(PetscInt, PetscInt, PetscInt,
12456528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12466528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12476528b96dSMatthew G. Knepley                                                           PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
12486528b96dSMatthew G. Knepley {
12496528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
12506528b96dSMatthew G. Knepley   PetscErrorCode ierr;
12516528b96dSMatthew G. Knepley 
12526528b96dSMatthew G. Knepley   PetscFunctionBegin;
1253*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_GT0], label, val, find, part, n0, (void (**)(void)) g0);CHKERRQ(ierr);
1254*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_GT1], label, val, find, part, n1, (void (**)(void)) g1);CHKERRQ(ierr);
1255*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_GT2], label, val, find, part, n2, (void (**)(void)) g2);CHKERRQ(ierr);
1256*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_GT3], label, val, find, part, n3, (void (**)(void)) g3);CHKERRQ(ierr);
12576528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
12586528b96dSMatthew G. Knepley }
12596528b96dSMatthew G. Knepley 
1260*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormSetIndexDynamicJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part,
12616528b96dSMatthew G. Knepley                                                PetscInt i0,
12626528b96dSMatthew G. Knepley                                                void (*g0)(PetscInt, PetscInt, PetscInt,
12636528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12646528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12656528b96dSMatthew G. Knepley                                                           PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
12666528b96dSMatthew G. Knepley                                                PetscInt i1,
12676528b96dSMatthew G. Knepley                                                void (*g1)(PetscInt, PetscInt, PetscInt,
12686528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12696528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12706528b96dSMatthew G. Knepley                                                           PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
12716528b96dSMatthew G. Knepley                                                PetscInt i2,
12726528b96dSMatthew G. Knepley                                                void (*g2)(PetscInt, PetscInt, PetscInt,
12736528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12746528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12756528b96dSMatthew G. Knepley                                                           PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]),
12766528b96dSMatthew G. Knepley                                                PetscInt i3,
12776528b96dSMatthew G. Knepley                                                void (*g3)(PetscInt, PetscInt, PetscInt,
12786528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12796528b96dSMatthew G. Knepley                                                           const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
12806528b96dSMatthew G. Knepley                                                           PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
12816528b96dSMatthew G. Knepley {
12826528b96dSMatthew G. Knepley   PetscInt       find = f*wf->Nf + g;
12836528b96dSMatthew G. Knepley   PetscErrorCode ierr;
12846528b96dSMatthew G. Knepley 
12856528b96dSMatthew G. Knepley   PetscFunctionBegin;
1286*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_GT0], label, val, find, part, i0, (void (*)(void)) g0);CHKERRQ(ierr);
1287*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_GT1], label, val, find, part, i1, (void (*)(void)) g1);CHKERRQ(ierr);
1288*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_GT2], label, val, find, part, i2, (void (*)(void)) g2);CHKERRQ(ierr);
1289*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_GT3], label, val, find, part, i3, (void (*)(void)) g3);CHKERRQ(ierr);
12906528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
12916528b96dSMatthew G. Knepley }
12926528b96dSMatthew G. Knepley 
1293*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormGetRiemannSolver(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part, PetscInt *n,
12946528b96dSMatthew G. Knepley                                              void (***r)(PetscInt, PetscInt, const PetscReal[], const PetscReal[], const PetscScalar[], const PetscScalar[], PetscInt, const PetscScalar[], PetscScalar[], void *))
12956528b96dSMatthew G. Knepley {
12966528b96dSMatthew G. Knepley   PetscErrorCode ierr;
12976528b96dSMatthew G. Knepley 
12986528b96dSMatthew G. Knepley   PetscFunctionBegin;
1299*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_R], label, val, f, part, n, (void (***)(void)) r);CHKERRQ(ierr);
13006528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
13016528b96dSMatthew G. Knepley }
13026528b96dSMatthew G. Knepley 
1303*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormSetRiemannSolver(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part,
13046528b96dSMatthew G. Knepley                                              PetscInt n,
13056528b96dSMatthew G. Knepley                                              void (**r)(PetscInt, PetscInt, const PetscReal[], const PetscReal[], const PetscScalar[], const PetscScalar[], PetscInt, const PetscScalar[], PetscScalar[], void *))
13066528b96dSMatthew G. Knepley {
13076528b96dSMatthew G. Knepley   PetscErrorCode ierr;
13086528b96dSMatthew G. Knepley 
13096528b96dSMatthew G. Knepley   PetscFunctionBegin;
1310*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_R], label, val, f, part, n, (void (**)(void)) r);CHKERRQ(ierr);
13116528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
13126528b96dSMatthew G. Knepley }
13136528b96dSMatthew G. Knepley 
1314*06ad1575SMatthew G. Knepley PetscErrorCode PetscWeakFormSetIndexRiemannSolver(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part,
13156528b96dSMatthew G. Knepley                                                   PetscInt i,
13166528b96dSMatthew G. Knepley                                                   void (*r)(PetscInt, PetscInt, const PetscReal[], const PetscReal[], const PetscScalar[], const PetscScalar[], PetscInt, const PetscScalar[], PetscScalar[], void *))
13176528b96dSMatthew G. Knepley {
13186528b96dSMatthew G. Knepley   PetscErrorCode ierr;
13196528b96dSMatthew G. Knepley 
13206528b96dSMatthew G. Knepley   PetscFunctionBegin;
1321*06ad1575SMatthew G. Knepley   ierr = PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_R], label, val, f, part, i, (void (*)(void)) r);CHKERRQ(ierr);
13226528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
13236528b96dSMatthew G. Knepley }
13246528b96dSMatthew G. Knepley 
13256528b96dSMatthew G. Knepley /*@
13266528b96dSMatthew G. Knepley   PetscWeakFormGetNumFields - Returns the number of fields
13276528b96dSMatthew G. Knepley 
13286528b96dSMatthew G. Knepley   Not collective
13296528b96dSMatthew G. Knepley 
13306528b96dSMatthew G. Knepley   Input Parameter:
13316528b96dSMatthew G. Knepley . wf - The PetscWeakForm object
13326528b96dSMatthew G. Knepley 
13336528b96dSMatthew G. Knepley   Output Parameter:
13346528b96dSMatthew G. Knepley . Nf - The nubmer of fields
13356528b96dSMatthew G. Knepley 
13366528b96dSMatthew G. Knepley   Level: beginner
13376528b96dSMatthew G. Knepley 
13386528b96dSMatthew G. Knepley .seealso: PetscWeakFormSetNumFields(), PetscWeakFormCreate()
13396528b96dSMatthew G. Knepley @*/
13406528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormGetNumFields(PetscWeakForm wf, PetscInt *Nf)
13416528b96dSMatthew G. Knepley {
13426528b96dSMatthew G. Knepley   PetscFunctionBegin;
13436528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
13446528b96dSMatthew G. Knepley   PetscValidPointer(Nf, 2);
13456528b96dSMatthew G. Knepley   *Nf = wf->Nf;
13466528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
13476528b96dSMatthew G. Knepley }
13486528b96dSMatthew G. Knepley 
13496528b96dSMatthew G. Knepley /*@
13506528b96dSMatthew G. Knepley   PetscWeakFormSetNumFields - Sets the number of fields
13516528b96dSMatthew G. Knepley 
13526528b96dSMatthew G. Knepley   Not collective
13536528b96dSMatthew G. Knepley 
13546528b96dSMatthew G. Knepley   Input Parameters:
13556528b96dSMatthew G. Knepley + wf - The PetscWeakForm object
13566528b96dSMatthew G. Knepley - Nf - The number of fields
13576528b96dSMatthew G. Knepley 
13586528b96dSMatthew G. Knepley   Level: beginner
13596528b96dSMatthew G. Knepley 
13606528b96dSMatthew G. Knepley .seealso: PetscWeakFormGetNumFields(), PetscWeakFormCreate()
13616528b96dSMatthew G. Knepley @*/
13626528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormSetNumFields(PetscWeakForm wf, PetscInt Nf)
13636528b96dSMatthew G. Knepley {
13646528b96dSMatthew G. Knepley   PetscFunctionBegin;
13656528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
13666528b96dSMatthew G. Knepley   wf->Nf = Nf;
13676528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
13686528b96dSMatthew G. Knepley }
13696528b96dSMatthew G. Knepley 
13706528b96dSMatthew G. Knepley /*@
13716528b96dSMatthew G. Knepley   PetscWeakFormDestroy - Destroys a PetscWeakForm object
13726528b96dSMatthew G. Knepley 
13736528b96dSMatthew G. Knepley   Collective on wf
13746528b96dSMatthew G. Knepley 
13756528b96dSMatthew G. Knepley   Input Parameter:
13766528b96dSMatthew G. Knepley . wf - the PetscWeakForm object to destroy
13776528b96dSMatthew G. Knepley 
13786528b96dSMatthew G. Knepley   Level: developer
13796528b96dSMatthew G. Knepley 
13806528b96dSMatthew G. Knepley .seealso PetscWeakFormCreate(), PetscWeakFormView()
13816528b96dSMatthew G. Knepley @*/
13826528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormDestroy(PetscWeakForm *wf)
13836528b96dSMatthew G. Knepley {
1384*06ad1575SMatthew G. Knepley   PetscInt       f;
13856528b96dSMatthew G. Knepley   PetscErrorCode ierr;
13866528b96dSMatthew G. Knepley 
13876528b96dSMatthew G. Knepley   PetscFunctionBegin;
13886528b96dSMatthew G. Knepley   if (!*wf) PetscFunctionReturn(0);
13896528b96dSMatthew G. Knepley   PetscValidHeaderSpecific((*wf), PETSCWEAKFORM_CLASSID, 1);
13906528b96dSMatthew G. Knepley 
13916528b96dSMatthew G. Knepley   if (--((PetscObject)(*wf))->refct > 0) {*wf = NULL; PetscFunctionReturn(0);}
13926528b96dSMatthew G. Knepley   ((PetscObject) (*wf))->refct = 0;
13936528b96dSMatthew G. Knepley   ierr = PetscChunkBufferDestroy(&(*wf)->funcs);CHKERRQ(ierr);
1394*06ad1575SMatthew G. Knepley   for (f = 0; f < PETSC_NUM_WF; ++f) {ierr = PetscHMapFormDestroy(&(*wf)->form[f]);CHKERRQ(ierr);}
1395*06ad1575SMatthew G. Knepley   ierr = PetscFree((*wf)->form);CHKERRQ(ierr);
13966528b96dSMatthew G. Knepley   ierr = PetscHeaderDestroy(wf);CHKERRQ(ierr);
13976528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
13986528b96dSMatthew G. Knepley }
13996528b96dSMatthew G. Knepley 
140045480ffeSMatthew G. Knepley static PetscErrorCode PetscWeakFormViewTable_Ascii(PetscWeakForm wf, PetscViewer viewer, PetscBool splitField, const char tableName[], PetscHMapForm map)
14016528b96dSMatthew G. Knepley {
140245480ffeSMatthew G. Knepley   PetscInt       Nf = wf->Nf, Nk, k;
14036528b96dSMatthew G. Knepley   PetscErrorCode ierr;
14046528b96dSMatthew G. Knepley 
14056528b96dSMatthew G. Knepley   PetscFunctionBegin;
14066528b96dSMatthew G. Knepley   ierr = PetscHMapFormGetSize(map, &Nk);CHKERRQ(ierr);
14076528b96dSMatthew G. Knepley   if (Nk) {
1408*06ad1575SMatthew G. Knepley     PetscFormKey *keys;
14096528b96dSMatthew G. Knepley     void           (**funcs)(void);
14106528b96dSMatthew G. Knepley     const char       *name;
14116528b96dSMatthew G. Knepley     PetscInt          off = 0, n, i;
14126528b96dSMatthew G. Knepley 
14136528b96dSMatthew G. Knepley     ierr = PetscMalloc1(Nk, &keys);CHKERRQ(ierr);
14146528b96dSMatthew G. Knepley     ierr = PetscHMapFormGetKeys(map, &off, keys);CHKERRQ(ierr);
14156528b96dSMatthew G. Knepley     ierr = PetscViewerASCIIPrintf(viewer, "%s\n", tableName);CHKERRQ(ierr);
14166528b96dSMatthew G. Knepley     ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr);
14176528b96dSMatthew G. Knepley     for (k = 0; k < Nk; ++k) {
141845480ffeSMatthew G. Knepley       if (keys[k].label) {
141945480ffeSMatthew G. Knepley         ierr = PetscObjectGetName((PetscObject) keys[k].label, &name);CHKERRQ(ierr);
142045480ffeSMatthew G. Knepley         ierr = PetscViewerASCIIPrintf(viewer, "(%s, %D) ", name, keys[k].value);CHKERRQ(ierr);
142145480ffeSMatthew G. Knepley       } else {ierr = PetscViewerASCIIPrintf(viewer, "");CHKERRQ(ierr);}
14226528b96dSMatthew G. Knepley       ierr = PetscViewerASCIIUseTabs(viewer, PETSC_FALSE);CHKERRQ(ierr);
142345480ffeSMatthew G. Knepley       if (splitField) {ierr = PetscViewerASCIIPrintf(viewer, "(%D, %D) ", keys[k].field/Nf, keys[k].field%Nf);CHKERRQ(ierr);}
142445480ffeSMatthew G. Knepley       else            {ierr = PetscViewerASCIIPrintf(viewer, "(%D) ", keys[k].field);CHKERRQ(ierr);}
1425*06ad1575SMatthew G. Knepley       ierr = PetscWeakFormGetFunction_Private(wf, map, keys[k].label, keys[k].value, keys[k].field, keys[k].part, &n, &funcs);CHKERRQ(ierr);
14266528b96dSMatthew G. Knepley       for (i = 0; i < n; ++i) {
1427258ec3d2SMatthew G. Knepley         char *fname;
1428258ec3d2SMatthew G. Knepley 
14296528b96dSMatthew G. Knepley         if (i > 0) {ierr = PetscViewerASCIIPrintf(viewer, ", ");CHKERRQ(ierr);}
1430258ec3d2SMatthew G. Knepley         ierr = PetscDLAddr(funcs[i], &fname);CHKERRQ(ierr);
1431258ec3d2SMatthew G. Knepley         if (fname) {ierr = PetscViewerASCIIPrintf(viewer, "%s", fname);CHKERRQ(ierr);}
14326528b96dSMatthew G. Knepley         else       {ierr = PetscViewerASCIIPrintf(viewer, "%p", funcs[i]);CHKERRQ(ierr);}
1433258ec3d2SMatthew G. Knepley         ierr = PetscFree(fname);CHKERRQ(ierr);
14346528b96dSMatthew G. Knepley       }
14356528b96dSMatthew G. Knepley       ierr = PetscViewerASCIIPrintf(viewer, "\n");CHKERRQ(ierr);
14366528b96dSMatthew G. Knepley       ierr = PetscViewerASCIIUseTabs(viewer, PETSC_TRUE);CHKERRQ(ierr);
14376528b96dSMatthew G. Knepley     }
14386528b96dSMatthew G. Knepley     ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr);
14396528b96dSMatthew G. Knepley     ierr = PetscFree(keys);CHKERRQ(ierr);
14406528b96dSMatthew G. Knepley   }
14416528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
14426528b96dSMatthew G. Knepley }
14436528b96dSMatthew G. Knepley 
14446528b96dSMatthew G. Knepley static PetscErrorCode PetscWeakFormView_Ascii(PetscWeakForm wf, PetscViewer viewer)
14456528b96dSMatthew G. Knepley {
14466528b96dSMatthew G. Knepley   PetscViewerFormat format;
1447*06ad1575SMatthew G. Knepley   PetscInt          f;
14486528b96dSMatthew G. Knepley   PetscErrorCode    ierr;
14496528b96dSMatthew G. Knepley 
14506528b96dSMatthew G. Knepley   PetscFunctionBegin;
14516528b96dSMatthew G. Knepley   ierr = PetscViewerGetFormat(viewer, &format);CHKERRQ(ierr);
14526528b96dSMatthew G. Knepley   ierr = PetscViewerASCIIPrintf(viewer, "Weak Form System with %d fields\n", wf->Nf);CHKERRQ(ierr);
14536528b96dSMatthew G. Knepley   ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr);
1454*06ad1575SMatthew G. Knepley   for (f = 0; f < PETSC_NUM_WF; ++f) {
1455*06ad1575SMatthew G. Knepley     ierr = PetscWeakFormViewTable_Ascii(wf, viewer, PETSC_FALSE, PetscWeakFormKinds[f], wf->form[f]);CHKERRQ(ierr);
1456*06ad1575SMatthew G. Knepley   }
14576528b96dSMatthew G. Knepley   ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr);
14586528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
14596528b96dSMatthew G. Knepley }
14606528b96dSMatthew G. Knepley 
14616528b96dSMatthew G. Knepley /*@C
14626528b96dSMatthew G. Knepley   PetscWeakFormView - Views a PetscWeakForm
14636528b96dSMatthew G. Knepley 
14646528b96dSMatthew G. Knepley   Collective on wf
14656528b96dSMatthew G. Knepley 
14666528b96dSMatthew G. Knepley   Input Parameter:
14676528b96dSMatthew G. Knepley + wf - the PetscWeakForm object to view
14686528b96dSMatthew G. Knepley - v  - the viewer
14696528b96dSMatthew G. Knepley 
14706528b96dSMatthew G. Knepley   Level: developer
14716528b96dSMatthew G. Knepley 
14726528b96dSMatthew G. Knepley .seealso PetscWeakFormDestroy(), PetscWeakFormCreate()
14736528b96dSMatthew G. Knepley @*/
14746528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormView(PetscWeakForm wf, PetscViewer v)
14756528b96dSMatthew G. Knepley {
14766528b96dSMatthew G. Knepley   PetscBool      iascii;
14776528b96dSMatthew G. Knepley   PetscErrorCode ierr;
14786528b96dSMatthew G. Knepley 
14796528b96dSMatthew G. Knepley   PetscFunctionBegin;
14806528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
14816528b96dSMatthew G. Knepley   if (!v) {ierr = PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject) wf), &v);CHKERRQ(ierr);}
14826528b96dSMatthew G. Knepley   else    {PetscValidHeaderSpecific(v, PETSC_VIEWER_CLASSID, 2);}
14836528b96dSMatthew G. Knepley   ierr = PetscObjectTypeCompare((PetscObject) v, PETSCVIEWERASCII, &iascii);CHKERRQ(ierr);
14846528b96dSMatthew G. Knepley   if (iascii) {ierr = PetscWeakFormView_Ascii(wf, v);CHKERRQ(ierr);}
14856528b96dSMatthew G. Knepley   if (wf->ops->view) {ierr = (*wf->ops->view)(wf, v);CHKERRQ(ierr);}
14866528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
14876528b96dSMatthew G. Knepley }
14886528b96dSMatthew G. Knepley 
14896528b96dSMatthew G. Knepley /*@
14906528b96dSMatthew G. Knepley   PetscWeakFormCreate - Creates an empty PetscWeakForm object.
14916528b96dSMatthew G. Knepley 
14926528b96dSMatthew G. Knepley   Collective
14936528b96dSMatthew G. Knepley 
14946528b96dSMatthew G. Knepley   Input Parameter:
14956528b96dSMatthew G. Knepley . comm - The communicator for the PetscWeakForm object
14966528b96dSMatthew G. Knepley 
14976528b96dSMatthew G. Knepley   Output Parameter:
14986528b96dSMatthew G. Knepley . wf - The PetscWeakForm object
14996528b96dSMatthew G. Knepley 
15006528b96dSMatthew G. Knepley   Level: beginner
15016528b96dSMatthew G. Knepley 
15026528b96dSMatthew G. Knepley .seealso: PetscDS, PetscWeakFormDestroy()
15036528b96dSMatthew G. Knepley @*/
15046528b96dSMatthew G. Knepley PetscErrorCode PetscWeakFormCreate(MPI_Comm comm, PetscWeakForm *wf)
15056528b96dSMatthew G. Knepley {
15066528b96dSMatthew G. Knepley   PetscWeakForm  p;
1507*06ad1575SMatthew G. Knepley   PetscInt       f;
15086528b96dSMatthew G. Knepley   PetscErrorCode ierr;
15096528b96dSMatthew G. Knepley 
15106528b96dSMatthew G. Knepley   PetscFunctionBegin;
15116528b96dSMatthew G. Knepley   PetscValidPointer(wf, 2);
15126528b96dSMatthew G. Knepley   *wf  = NULL;
15136528b96dSMatthew G. Knepley   ierr = PetscDSInitializePackage();CHKERRQ(ierr);
15146528b96dSMatthew G. Knepley 
15156528b96dSMatthew G. Knepley   ierr = PetscHeaderCreate(p, PETSCWEAKFORM_CLASSID, "PetscWeakForm", "Weak Form System", "PetscWeakForm", comm, PetscWeakFormDestroy, PetscWeakFormView);CHKERRQ(ierr);
15166528b96dSMatthew G. Knepley 
15176528b96dSMatthew G. Knepley   p->Nf = 0;
15186528b96dSMatthew G. Knepley   ierr = PetscChunkBufferCreate(sizeof(&PetscWeakFormCreate), 2, &p->funcs);CHKERRQ(ierr);
1519*06ad1575SMatthew G. Knepley   ierr = PetscMalloc1(PETSC_NUM_WF, &p->form);CHKERRQ(ierr);
1520*06ad1575SMatthew G. Knepley   for (f = 0; f < PETSC_NUM_WF; ++f) {ierr = PetscHMapFormCreate(&p->form[f]);CHKERRQ(ierr);}
15216528b96dSMatthew G. Knepley   *wf = p;
15226528b96dSMatthew G. Knepley   PetscFunctionReturn(0);
15236528b96dSMatthew G. Knepley }
1524