xref: /petsc/src/dm/dt/interface/dtweakform.c (revision 2286efddd54511ab18e8e2adb1e023c4bf8f0b92)
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 
506ad1575SMatthew 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};
606ad1575SMatthew G. Knepley 
PetscChunkBufferCreate(size_t unitbytes,PetscCount expected,PetscChunkBuffer * buffer[])76497c311SBarry Smith static PetscErrorCode PetscChunkBufferCreate(size_t unitbytes, PetscCount expected, PetscChunkBuffer *buffer[])
8d71ae5a4SJacob Faibussowitsch {
96528b96dSMatthew G. Knepley   PetscFunctionBegin;
109566063dSJacob Faibussowitsch   PetscCall(PetscNew(buffer));
119566063dSJacob Faibussowitsch   PetscCall(PetscCalloc1(expected * unitbytes, &(*buffer)->array));
126528b96dSMatthew G. Knepley   (*buffer)->size      = expected;
136528b96dSMatthew G. Knepley   (*buffer)->unitbytes = unitbytes;
146528b96dSMatthew G. Knepley   (*buffer)->alloc     = expected * unitbytes;
153ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
166528b96dSMatthew G. Knepley }
176528b96dSMatthew G. Knepley 
PetscChunkBufferDuplicate(PetscChunkBuffer * buffer,PetscChunkBuffer * bufferNew[])186497c311SBarry Smith static PetscErrorCode PetscChunkBufferDuplicate(PetscChunkBuffer *buffer, PetscChunkBuffer *bufferNew[])
19d71ae5a4SJacob Faibussowitsch {
2045480ffeSMatthew G. Knepley   PetscFunctionBegin;
219566063dSJacob Faibussowitsch   PetscCall(PetscNew(bufferNew));
229566063dSJacob Faibussowitsch   PetscCall(PetscCalloc1(buffer->size * buffer->unitbytes, &(*bufferNew)->array));
239566063dSJacob Faibussowitsch   PetscCall(PetscMemcpy((*bufferNew)->array, buffer->array, buffer->size * buffer->unitbytes));
2445480ffeSMatthew G. Knepley   (*bufferNew)->size      = buffer->size;
2545480ffeSMatthew G. Knepley   (*bufferNew)->unitbytes = buffer->unitbytes;
2645480ffeSMatthew G. Knepley   (*bufferNew)->alloc     = buffer->size * buffer->unitbytes;
273ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
2845480ffeSMatthew G. Knepley }
2945480ffeSMatthew G. Knepley 
PetscChunkBufferDestroy(PetscChunkBuffer ** buffer)30d71ae5a4SJacob Faibussowitsch static PetscErrorCode PetscChunkBufferDestroy(PetscChunkBuffer **buffer)
31d71ae5a4SJacob Faibussowitsch {
326528b96dSMatthew G. Knepley   PetscFunctionBegin;
339566063dSJacob Faibussowitsch   PetscCall(PetscFree((*buffer)->array));
349566063dSJacob Faibussowitsch   PetscCall(PetscFree(*buffer));
353ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
366528b96dSMatthew G. Knepley }
376528b96dSMatthew G. Knepley 
PetscChunkBufferCreateChunk(PetscChunkBuffer * buffer,PetscCount size,PetscChunk * chunk)386497c311SBarry Smith static PetscErrorCode PetscChunkBufferCreateChunk(PetscChunkBuffer *buffer, PetscCount size, PetscChunk *chunk)
39d71ae5a4SJacob Faibussowitsch {
406528b96dSMatthew G. Knepley   PetscFunctionBegin;
416528b96dSMatthew G. Knepley   if ((buffer->size + size) * buffer->unitbytes > buffer->alloc) {
426528b96dSMatthew G. Knepley     char *tmp;
436528b96dSMatthew G. Knepley 
446528b96dSMatthew G. Knepley     if (!buffer->alloc) buffer->alloc = (buffer->size + size) * buffer->unitbytes;
456528b96dSMatthew G. Knepley     while ((buffer->size + size) * buffer->unitbytes > buffer->alloc) buffer->alloc *= 2;
469566063dSJacob Faibussowitsch     PetscCall(PetscMalloc(buffer->alloc, &tmp));
479566063dSJacob Faibussowitsch     PetscCall(PetscMemcpy(tmp, buffer->array, buffer->size * buffer->unitbytes));
489566063dSJacob Faibussowitsch     PetscCall(PetscFree(buffer->array));
496528b96dSMatthew G. Knepley     buffer->array = tmp;
506528b96dSMatthew G. Knepley   }
512baeeceeSMatthew G. Knepley   chunk->start    = buffer->size * buffer->unitbytes;
526528b96dSMatthew G. Knepley   chunk->size     = size;
536528b96dSMatthew G. Knepley   chunk->reserved = size;
546528b96dSMatthew G. Knepley   buffer->size += size;
553ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
566528b96dSMatthew G. Knepley }
576528b96dSMatthew G. Knepley 
PetscChunkBufferEnlargeChunk(PetscChunkBuffer * buffer,PetscCount size,PetscChunk * chunk)586497c311SBarry Smith static PetscErrorCode PetscChunkBufferEnlargeChunk(PetscChunkBuffer *buffer, PetscCount size, PetscChunk *chunk)
59d71ae5a4SJacob Faibussowitsch {
606528b96dSMatthew G. Knepley   size_t siz = size;
616528b96dSMatthew G. Knepley 
626528b96dSMatthew G. Knepley   PetscFunctionBegin;
636528b96dSMatthew G. Knepley   if (chunk->size + size > chunk->reserved) {
646528b96dSMatthew G. Knepley     PetscChunk newchunk;
656497c311SBarry Smith     PetscCount reserved = chunk->size;
666528b96dSMatthew G. Knepley 
676528b96dSMatthew G. Knepley     /* TODO Here if we had a chunk list, we could update them all to reclaim unused space */
686528b96dSMatthew G. Knepley     while (reserved < chunk->size + size) reserved *= 2;
699566063dSJacob Faibussowitsch     PetscCall(PetscChunkBufferCreateChunk(buffer, (size_t)reserved, &newchunk));
706528b96dSMatthew G. Knepley     newchunk.size = chunk->size + size;
719566063dSJacob Faibussowitsch     PetscCall(PetscMemcpy(&buffer->array[newchunk.start], &buffer->array[chunk->start], chunk->size * buffer->unitbytes));
726528b96dSMatthew G. Knepley     *chunk = newchunk;
736528b96dSMatthew G. Knepley   } else {
746528b96dSMatthew G. Knepley     chunk->size += siz;
756528b96dSMatthew G. Knepley   }
763ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
776528b96dSMatthew G. Knepley }
786528b96dSMatthew G. Knepley 
796528b96dSMatthew G. Knepley /*@C
80dce8aebaSBarry Smith   PetscFormKeySort - Sorts an array of `PetscFormKey` in place in increasing order.
816528b96dSMatthew G. Knepley 
826528b96dSMatthew G. Knepley   Not Collective
836528b96dSMatthew G. Knepley 
846528b96dSMatthew G. Knepley   Input Parameters:
856528b96dSMatthew G. Knepley + n   - number of values
8660225df5SJacob Faibussowitsch - arr - array of `PetscFormKey`
876528b96dSMatthew G. Knepley 
886528b96dSMatthew G. Knepley   Level: intermediate
896528b96dSMatthew G. Knepley 
90dce8aebaSBarry Smith .seealso: `PetscFormKey`, `PetscIntSortSemiOrdered()`, `PetscSortInt()`
916528b96dSMatthew G. Knepley @*/
PetscFormKeySort(PetscInt n,PetscFormKey arr[])92d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscFormKeySort(PetscInt n, PetscFormKey arr[])
93d71ae5a4SJacob Faibussowitsch {
946528b96dSMatthew G. Knepley   PetscFunctionBegin;
953ba16761SJacob Faibussowitsch   if (n <= 1) PetscFunctionReturn(PETSC_SUCCESS);
964f572ea9SToby Isaac   PetscAssertPointer(arr, 2);
979566063dSJacob Faibussowitsch   PetscCall(PetscTimSort(n, arr, sizeof(PetscFormKey), Compare_PetscFormKey_Private, NULL));
983ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
996528b96dSMatthew G. Knepley }
1006528b96dSMatthew G. Knepley 
PetscWeakFormGetFunction_Private(PetscWeakForm wf,PetscHMapForm ht,DMLabel label,PetscInt value,PetscInt f,PetscInt part,PetscInt * n,void (*** func)(void))10166976f2fSJacob Faibussowitsch static PetscErrorCode PetscWeakFormGetFunction_Private(PetscWeakForm wf, PetscHMapForm ht, DMLabel label, PetscInt value, PetscInt f, PetscInt part, PetscInt *n, void (***func)(void))
102d71ae5a4SJacob Faibussowitsch {
10306ad1575SMatthew G. Knepley   PetscFormKey key;
1046528b96dSMatthew G. Knepley   PetscChunk   chunk;
1056528b96dSMatthew G. Knepley 
1066528b96dSMatthew G. Knepley   PetscFunctionBegin;
1079371c9d4SSatish Balay   key.label = label;
1089371c9d4SSatish Balay   key.value = value;
1099371c9d4SSatish Balay   key.field = f;
1109371c9d4SSatish Balay   key.part  = part;
1119566063dSJacob Faibussowitsch   PetscCall(PetscHMapFormGet(ht, key, &chunk));
1129371c9d4SSatish Balay   if (chunk.size < 0) {
1139371c9d4SSatish Balay     *n    = 0;
1149371c9d4SSatish Balay     *func = NULL;
1159371c9d4SSatish Balay   } else {
1166497c311SBarry Smith     PetscCall(PetscIntCast(chunk.size, n));
117*57d50842SBarry Smith     *func = (PetscVoidFn **)&wf->funcs->array[chunk.start];
1189371c9d4SSatish Balay   }
1193ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
1206528b96dSMatthew G. Knepley }
1216528b96dSMatthew G. Knepley 
1226528b96dSMatthew G. Knepley /* A NULL argument for func causes this to clear the key */
PetscWeakFormSetFunction_Private(PetscWeakForm wf,PetscHMapForm ht,DMLabel label,PetscInt value,PetscInt f,PetscInt part,PetscInt n,PetscVoidFn ** func)123*57d50842SBarry Smith static PetscErrorCode PetscWeakFormSetFunction_Private(PetscWeakForm wf, PetscHMapForm ht, DMLabel label, PetscInt value, PetscInt f, PetscInt part, PetscInt n, PetscVoidFn **func)
124d71ae5a4SJacob Faibussowitsch {
12506ad1575SMatthew G. Knepley   PetscFormKey key;
1266528b96dSMatthew G. Knepley   PetscChunk   chunk;
1276528b96dSMatthew G. Knepley   PetscInt     i;
1286528b96dSMatthew G. Knepley 
1296528b96dSMatthew G. Knepley   PetscFunctionBegin;
1309371c9d4SSatish Balay   key.label = label;
1319371c9d4SSatish Balay   key.value = value;
1329371c9d4SSatish Balay   key.field = f;
1339371c9d4SSatish Balay   key.part  = part;
1346528b96dSMatthew G. Knepley   if (!func) {
1359566063dSJacob Faibussowitsch     PetscCall(PetscHMapFormDel(ht, key));
1363ba16761SJacob Faibussowitsch     PetscFunctionReturn(PETSC_SUCCESS);
1371baa6e33SBarry Smith   } else PetscCall(PetscHMapFormGet(ht, key, &chunk));
1386528b96dSMatthew G. Knepley   if (chunk.size < 0) {
1399566063dSJacob Faibussowitsch     PetscCall(PetscChunkBufferCreateChunk(wf->funcs, n, &chunk));
1409566063dSJacob Faibussowitsch     PetscCall(PetscHMapFormSet(ht, key, chunk));
1416528b96dSMatthew G. Knepley   } else if (chunk.size <= n) {
1429566063dSJacob Faibussowitsch     PetscCall(PetscChunkBufferEnlargeChunk(wf->funcs, n - chunk.size, &chunk));
1439566063dSJacob Faibussowitsch     PetscCall(PetscHMapFormSet(ht, key, chunk));
1446528b96dSMatthew G. Knepley   }
145*57d50842SBarry Smith   for (i = 0; i < n; ++i) ((PetscVoidFn **)&wf->funcs->array[chunk.start])[i] = func[i];
1463ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
1476528b96dSMatthew G. Knepley }
1486528b96dSMatthew G. Knepley 
PetscWeakFormAddFunction_Private(PetscWeakForm wf,PetscHMapForm ht,DMLabel label,PetscInt value,PetscInt f,PetscInt part,PetscVoidFn * func)149*57d50842SBarry Smith static PetscErrorCode PetscWeakFormAddFunction_Private(PetscWeakForm wf, PetscHMapForm ht, DMLabel label, PetscInt value, PetscInt f, PetscInt part, PetscVoidFn *func)
150d71ae5a4SJacob Faibussowitsch {
15106ad1575SMatthew G. Knepley   PetscFormKey key;
1526528b96dSMatthew G. Knepley   PetscChunk   chunk;
1536528b96dSMatthew G. Knepley 
1546528b96dSMatthew G. Knepley   PetscFunctionBegin;
1553ba16761SJacob Faibussowitsch   if (!func) PetscFunctionReturn(PETSC_SUCCESS);
1569371c9d4SSatish Balay   key.label = label;
1579371c9d4SSatish Balay   key.value = value;
1589371c9d4SSatish Balay   key.field = f;
1599371c9d4SSatish Balay   key.part  = part;
1609566063dSJacob Faibussowitsch   PetscCall(PetscHMapFormGet(ht, key, &chunk));
1616528b96dSMatthew G. Knepley   if (chunk.size < 0) {
1629566063dSJacob Faibussowitsch     PetscCall(PetscChunkBufferCreateChunk(wf->funcs, 1, &chunk));
1639566063dSJacob Faibussowitsch     PetscCall(PetscHMapFormSet(ht, key, chunk));
164*57d50842SBarry Smith     ((PetscVoidFn **)&wf->funcs->array[chunk.start])[0] = func;
1656528b96dSMatthew G. Knepley   } else {
1669566063dSJacob Faibussowitsch     PetscCall(PetscChunkBufferEnlargeChunk(wf->funcs, 1, &chunk));
1679566063dSJacob Faibussowitsch     PetscCall(PetscHMapFormSet(ht, key, chunk));
168*57d50842SBarry Smith     ((PetscVoidFn **)&wf->funcs->array[chunk.start])[chunk.size - 1] = func;
1696528b96dSMatthew G. Knepley   }
1703ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
1716528b96dSMatthew G. Knepley }
1726528b96dSMatthew G. Knepley 
PetscWeakFormGetIndexFunction_Private(PetscWeakForm wf,PetscHMapForm ht,DMLabel label,PetscInt value,PetscInt f,PetscInt part,PetscInt ind,PetscVoidFn ** func)173*57d50842SBarry Smith static PetscErrorCode PetscWeakFormGetIndexFunction_Private(PetscWeakForm wf, PetscHMapForm ht, DMLabel label, PetscInt value, PetscInt f, PetscInt part, PetscInt ind, PetscVoidFn **func)
174d71ae5a4SJacob Faibussowitsch {
17506ad1575SMatthew G. Knepley   PetscFormKey key;
1766528b96dSMatthew G. Knepley   PetscChunk   chunk;
1776528b96dSMatthew G. Knepley 
1786528b96dSMatthew G. Knepley   PetscFunctionBegin;
1799371c9d4SSatish Balay   key.label = label;
1809371c9d4SSatish Balay   key.value = value;
1819371c9d4SSatish Balay   key.field = f;
1829371c9d4SSatish Balay   key.part  = part;
1839566063dSJacob Faibussowitsch   PetscCall(PetscHMapFormGet(ht, key, &chunk));
1849371c9d4SSatish Balay   if (chunk.size < 0) {
1859371c9d4SSatish Balay     *func = NULL;
1869371c9d4SSatish Balay   } else {
1876497c311SBarry Smith     PetscCheck(ind < chunk.size, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Index %" PetscInt_FMT " not in [0, %" PetscCount_FMT ")", ind, chunk.size);
188*57d50842SBarry Smith     *func = ((PetscVoidFn **)&wf->funcs->array[chunk.start])[ind];
1896528b96dSMatthew G. Knepley   }
1903ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
1916528b96dSMatthew G. Knepley }
1926528b96dSMatthew G. Knepley 
19306ad1575SMatthew G. Knepley /* Ignore a NULL func */
PetscWeakFormSetIndexFunction_Private(PetscWeakForm wf,PetscHMapForm ht,DMLabel label,PetscInt value,PetscInt f,PetscInt part,PetscInt ind,PetscVoidFn * func)194*57d50842SBarry Smith static PetscErrorCode PetscWeakFormSetIndexFunction_Private(PetscWeakForm wf, PetscHMapForm ht, DMLabel label, PetscInt value, PetscInt f, PetscInt part, PetscInt ind, PetscVoidFn *func)
195d71ae5a4SJacob Faibussowitsch {
19606ad1575SMatthew G. Knepley   PetscFormKey key;
1976528b96dSMatthew G. Knepley   PetscChunk   chunk;
1986528b96dSMatthew G. Knepley 
1996528b96dSMatthew G. Knepley   PetscFunctionBegin;
2003ba16761SJacob Faibussowitsch   if (!func) PetscFunctionReturn(PETSC_SUCCESS);
2019371c9d4SSatish Balay   key.label = label;
2029371c9d4SSatish Balay   key.value = value;
2039371c9d4SSatish Balay   key.field = f;
2049371c9d4SSatish Balay   key.part  = part;
2059566063dSJacob Faibussowitsch   PetscCall(PetscHMapFormGet(ht, key, &chunk));
2066528b96dSMatthew G. Knepley   if (chunk.size < 0) {
2079566063dSJacob Faibussowitsch     PetscCall(PetscChunkBufferCreateChunk(wf->funcs, ind + 1, &chunk));
2089566063dSJacob Faibussowitsch     PetscCall(PetscHMapFormSet(ht, key, chunk));
2096528b96dSMatthew G. Knepley   } else if (chunk.size <= ind) {
2109566063dSJacob Faibussowitsch     PetscCall(PetscChunkBufferEnlargeChunk(wf->funcs, ind - chunk.size + 1, &chunk));
2119566063dSJacob Faibussowitsch     PetscCall(PetscHMapFormSet(ht, key, chunk));
2126528b96dSMatthew G. Knepley   }
213*57d50842SBarry Smith   ((PetscVoidFn **)&wf->funcs->array[chunk.start])[ind] = func;
2143ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
2156528b96dSMatthew G. Knepley }
2166528b96dSMatthew G. Knepley 
PetscWeakFormClearIndexFunction_Private(PetscWeakForm wf,PetscHMapForm ht,DMLabel label,PetscInt value,PetscInt f,PetscInt part,PetscInt ind)21766976f2fSJacob Faibussowitsch static PetscErrorCode PetscWeakFormClearIndexFunction_Private(PetscWeakForm wf, PetscHMapForm ht, DMLabel label, PetscInt value, PetscInt f, PetscInt part, PetscInt ind)
218d71ae5a4SJacob Faibussowitsch {
21906ad1575SMatthew G. Knepley   PetscFormKey key;
22006ad1575SMatthew G. Knepley   PetscChunk   chunk;
22106ad1575SMatthew G. Knepley 
22206ad1575SMatthew G. Knepley   PetscFunctionBegin;
2239371c9d4SSatish Balay   key.label = label;
2249371c9d4SSatish Balay   key.value = value;
2259371c9d4SSatish Balay   key.field = f;
2269371c9d4SSatish Balay   key.part  = part;
2279566063dSJacob Faibussowitsch   PetscCall(PetscHMapFormGet(ht, key, &chunk));
22806ad1575SMatthew G. Knepley   if (chunk.size < 0) {
2293ba16761SJacob Faibussowitsch     PetscFunctionReturn(PETSC_SUCCESS);
23006ad1575SMatthew G. Knepley   } else if (!ind && chunk.size == 1) {
2319566063dSJacob Faibussowitsch     PetscCall(PetscHMapFormDel(ht, key));
2323ba16761SJacob Faibussowitsch     PetscFunctionReturn(PETSC_SUCCESS);
23306ad1575SMatthew G. Knepley   } else if (chunk.size <= ind) {
2343ba16761SJacob Faibussowitsch     PetscFunctionReturn(PETSC_SUCCESS);
23506ad1575SMatthew G. Knepley   }
236*57d50842SBarry Smith   ((PetscVoidFn **)&wf->funcs->array[chunk.start])[ind] = NULL;
2373ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
23806ad1575SMatthew G. Knepley }
23906ad1575SMatthew G. Knepley 
24045480ffeSMatthew G. Knepley /*@
241dce8aebaSBarry Smith   PetscWeakFormCopy - Copy the pointwise functions to another `PetscWeakForm`
24245480ffeSMatthew G. Knepley 
24345480ffeSMatthew G. Knepley   Not Collective
24445480ffeSMatthew G. Knepley 
24545480ffeSMatthew G. Knepley   Input Parameter:
246dce8aebaSBarry Smith . wf - The original `PetscWeakForm`
24745480ffeSMatthew G. Knepley 
24845480ffeSMatthew G. Knepley   Output Parameter:
249dce8aebaSBarry Smith . wfNew - The copy of the `PetscWeakForm`
25045480ffeSMatthew G. Knepley 
25145480ffeSMatthew G. Knepley   Level: intermediate
25245480ffeSMatthew G. Knepley 
253dce8aebaSBarry Smith .seealso: `PetscWeakForm`, `PetscWeakFormCreate()`, `PetscWeakFormDestroy()`
25445480ffeSMatthew G. Knepley @*/
PetscWeakFormCopy(PetscWeakForm wf,PetscWeakForm wfNew)255d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormCopy(PetscWeakForm wf, PetscWeakForm wfNew)
256d71ae5a4SJacob Faibussowitsch {
25706ad1575SMatthew G. Knepley   PetscInt f;
25845480ffeSMatthew G. Knepley 
25945480ffeSMatthew G. Knepley   PetscFunctionBegin;
26045480ffeSMatthew G. Knepley   wfNew->Nf = wf->Nf;
2619566063dSJacob Faibussowitsch   PetscCall(PetscChunkBufferDestroy(&wfNew->funcs));
2629566063dSJacob Faibussowitsch   PetscCall(PetscChunkBufferDuplicate(wf->funcs, &wfNew->funcs));
26306ad1575SMatthew G. Knepley   for (f = 0; f < PETSC_NUM_WF; ++f) {
2649566063dSJacob Faibussowitsch     PetscCall(PetscHMapFormDestroy(&wfNew->form[f]));
2659566063dSJacob Faibussowitsch     PetscCall(PetscHMapFormDuplicate(wf->form[f], &wfNew->form[f]));
26606ad1575SMatthew G. Knepley   }
2673ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
26806ad1575SMatthew G. Knepley }
26906ad1575SMatthew G. Knepley 
27006ad1575SMatthew G. Knepley /*@
271dce8aebaSBarry Smith   PetscWeakFormClear - Clear all functions from the `PetscWeakForm`
27206ad1575SMatthew G. Knepley 
27306ad1575SMatthew G. Knepley   Not Collective
27406ad1575SMatthew G. Knepley 
27506ad1575SMatthew G. Knepley   Input Parameter:
276dce8aebaSBarry Smith . wf - The original `PetscWeakForm`
27706ad1575SMatthew G. Knepley 
27806ad1575SMatthew G. Knepley   Level: intermediate
27906ad1575SMatthew G. Knepley 
280dce8aebaSBarry Smith .seealso: `PetscWeakForm`, `PetscWeakFormCopy()`, `PetscWeakFormCreate()`, `PetscWeakFormDestroy()`
28106ad1575SMatthew G. Knepley @*/
PetscWeakFormClear(PetscWeakForm wf)282d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormClear(PetscWeakForm wf)
283d71ae5a4SJacob Faibussowitsch {
28406ad1575SMatthew G. Knepley   PetscInt f;
28506ad1575SMatthew G. Knepley 
28606ad1575SMatthew G. Knepley   PetscFunctionBegin;
2879566063dSJacob Faibussowitsch   for (f = 0; f < PETSC_NUM_WF; ++f) PetscCall(PetscHMapFormClear(wf->form[f]));
2883ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
28945480ffeSMatthew G. Knepley }
29045480ffeSMatthew G. Knepley 
PetscWeakFormRewriteKeys_Internal(PetscWeakForm wf,PetscHMapForm hmap,DMLabel label,PetscInt Nv,const PetscInt values[])291d71ae5a4SJacob Faibussowitsch static PetscErrorCode PetscWeakFormRewriteKeys_Internal(PetscWeakForm wf, PetscHMapForm hmap, DMLabel label, PetscInt Nv, const PetscInt values[])
292d71ae5a4SJacob Faibussowitsch {
29306ad1575SMatthew G. Knepley   PetscFormKey *keys;
294*57d50842SBarry Smith   PetscVoidFn **tmpfuncs;
2952851cf14SMatthew G. Knepley   PetscInt      n, off = 0, maxNf = 0;
29645480ffeSMatthew G. Knepley 
29745480ffeSMatthew G. Knepley   PetscFunctionBegin;
2989566063dSJacob Faibussowitsch   PetscCall(PetscHMapFormGetSize(hmap, &n));
2999566063dSJacob Faibussowitsch   PetscCall(PetscMalloc1(n, &keys));
3009566063dSJacob Faibussowitsch   PetscCall(PetscHMapFormGetKeys(hmap, &off, keys));
3012851cf14SMatthew G. Knepley   // Need to make a copy since SetFunction() can invalidate the storage
3022851cf14SMatthew G. Knepley   for (PetscInt i = 0; i < n; ++i) {
3032851cf14SMatthew G. Knepley     if (keys[i].label == label) {
304*57d50842SBarry Smith       PetscVoidFn **funcs;
3052851cf14SMatthew G. Knepley       PetscInt      Nf;
3062851cf14SMatthew G. Knepley 
3072851cf14SMatthew G. Knepley       PetscCall(PetscWeakFormGetFunction_Private(wf, hmap, keys[i].label, keys[i].value, keys[i].field, keys[i].part, &Nf, &funcs));
3082851cf14SMatthew G. Knepley       maxNf = PetscMax(maxNf, Nf);
3092851cf14SMatthew G. Knepley     }
3102851cf14SMatthew G. Knepley   }
3112851cf14SMatthew G. Knepley   PetscCall(PetscMalloc1(maxNf, &tmpfuncs));
3122851cf14SMatthew G. Knepley   for (PetscInt i = 0; i < n; ++i) {
31345480ffeSMatthew G. Knepley     if (keys[i].label == label) {
31445480ffeSMatthew G. Knepley       PetscBool     clear = PETSC_TRUE;
315*57d50842SBarry Smith       PetscVoidFn **funcs;
31645480ffeSMatthew G. Knepley       PetscInt      Nf;
31745480ffeSMatthew G. Knepley 
3189566063dSJacob Faibussowitsch       PetscCall(PetscWeakFormGetFunction_Private(wf, hmap, keys[i].label, keys[i].value, keys[i].field, keys[i].part, &Nf, &funcs));
3192851cf14SMatthew G. Knepley       for (PetscInt f = 0; f < Nf; ++f) tmpfuncs[f] = funcs[f];
3202851cf14SMatthew G. Knepley       for (PetscInt v = 0; v < Nv; ++v) {
3212851cf14SMatthew G. Knepley         PetscCall(PetscWeakFormSetFunction_Private(wf, hmap, keys[i].label, values[v], keys[i].field, keys[i].part, Nf, tmpfuncs));
32245480ffeSMatthew G. Knepley         if (values[v] == keys[i].value) clear = PETSC_FALSE;
32345480ffeSMatthew G. Knepley       }
3249566063dSJacob Faibussowitsch       if (clear) PetscCall(PetscWeakFormSetFunction_Private(wf, hmap, keys[i].label, keys[i].value, keys[i].field, keys[i].part, 0, NULL));
32545480ffeSMatthew G. Knepley     }
32645480ffeSMatthew G. Knepley   }
3272851cf14SMatthew G. Knepley   PetscCall(PetscFree(tmpfuncs));
3289566063dSJacob Faibussowitsch   PetscCall(PetscFree(keys));
3293ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
33045480ffeSMatthew G. Knepley }
33145480ffeSMatthew G. Knepley 
332cc4c1da9SBarry Smith /*@
33345480ffeSMatthew G. Knepley   PetscWeakFormRewriteKeys - Change any key on the given label to use the new set of label values
33445480ffeSMatthew G. Knepley 
33545480ffeSMatthew G. Knepley   Not Collective
33645480ffeSMatthew G. Knepley 
33745480ffeSMatthew G. Knepley   Input Parameters:
338dce8aebaSBarry Smith + wf     - The original `PetscWeakForm`
33945480ffeSMatthew G. Knepley . label  - The label to change keys for
34045480ffeSMatthew G. Knepley . Nv     - The number of new label values
34145480ffeSMatthew G. Knepley - values - The set of new values to relabel keys with
34245480ffeSMatthew G. Knepley 
34345480ffeSMatthew G. Knepley   Level: intermediate
34445480ffeSMatthew G. Knepley 
345dce8aebaSBarry Smith   Note:
346dce8aebaSBarry Smith   This is used internally when boundary label values are specified from the command line.
347dce8aebaSBarry Smith 
348dce8aebaSBarry Smith .seealso: `PetscWeakForm`, `DMLabel`, `PetscWeakFormReplaceLabel()`, `PetscWeakFormCreate()`, `PetscWeakFormDestroy()`
34945480ffeSMatthew G. Knepley @*/
PetscWeakFormRewriteKeys(PetscWeakForm wf,DMLabel label,PetscInt Nv,const PetscInt values[])350d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormRewriteKeys(PetscWeakForm wf, DMLabel label, PetscInt Nv, const PetscInt values[])
351d71ae5a4SJacob Faibussowitsch {
35206ad1575SMatthew G. Knepley   PetscInt f;
35345480ffeSMatthew G. Knepley 
35445480ffeSMatthew G. Knepley   PetscFunctionBegin;
3559566063dSJacob Faibussowitsch   for (f = 0; f < PETSC_NUM_WF; ++f) PetscCall(PetscWeakFormRewriteKeys_Internal(wf, wf->form[f], label, Nv, values));
3563ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
35745480ffeSMatthew G. Knepley }
35845480ffeSMatthew G. Knepley 
PetscWeakFormReplaceLabel_Internal(PetscWeakForm wf,PetscHMapForm hmap,DMLabel label)359d71ae5a4SJacob Faibussowitsch static PetscErrorCode PetscWeakFormReplaceLabel_Internal(PetscWeakForm wf, PetscHMapForm hmap, DMLabel label)
360d71ae5a4SJacob Faibussowitsch {
361d700741fSMatthew G. Knepley   PetscFormKey *keys;
362d700741fSMatthew G. Knepley   PetscInt      n, i, off = 0, maxFuncs = 0;
363*57d50842SBarry Smith   PetscVoidFn **tmpf;
364d700741fSMatthew G. Knepley   const char   *name = NULL;
365d700741fSMatthew G. Knepley 
366d700741fSMatthew G. Knepley   PetscFunctionBegin;
3679566063dSJacob Faibussowitsch   if (label) PetscCall(PetscObjectGetName((PetscObject)label, &name));
3689566063dSJacob Faibussowitsch   PetscCall(PetscHMapFormGetSize(hmap, &n));
3699566063dSJacob Faibussowitsch   PetscCall(PetscMalloc1(n, &keys));
3709566063dSJacob Faibussowitsch   PetscCall(PetscHMapFormGetKeys(hmap, &off, keys));
371d700741fSMatthew G. Knepley   for (i = 0; i < n; ++i) {
372d700741fSMatthew G. Knepley     PetscBool   match = PETSC_FALSE;
373d700741fSMatthew G. Knepley     const char *lname = NULL;
374d700741fSMatthew G. Knepley 
375d700741fSMatthew G. Knepley     if (label == keys[i].label) continue;
3769566063dSJacob Faibussowitsch     if (keys[i].label) PetscCall(PetscObjectGetName((PetscObject)keys[i].label, &lname));
3779566063dSJacob Faibussowitsch     PetscCall(PetscStrcmp(name, lname, &match));
378d700741fSMatthew G. Knepley     if ((!name && !lname) || match) {
379*57d50842SBarry Smith       PetscVoidFn **funcs;
380d700741fSMatthew G. Knepley       PetscInt      Nf;
381d700741fSMatthew G. Knepley 
3829566063dSJacob Faibussowitsch       PetscCall(PetscWeakFormGetFunction_Private(wf, hmap, keys[i].label, keys[i].value, keys[i].field, keys[i].part, &Nf, &funcs));
383d700741fSMatthew G. Knepley       maxFuncs = PetscMax(maxFuncs, Nf);
384d700741fSMatthew G. Knepley     }
385d700741fSMatthew G. Knepley   }
386d700741fSMatthew G. Knepley   /* Need temp space because chunk buffer can be reallocated in SetFunction() call */
3879566063dSJacob Faibussowitsch   PetscCall(PetscMalloc1(maxFuncs, &tmpf));
388d700741fSMatthew G. Knepley   for (i = 0; i < n; ++i) {
389d700741fSMatthew G. Knepley     PetscBool   match = PETSC_FALSE;
390d700741fSMatthew G. Knepley     const char *lname = NULL;
391d700741fSMatthew G. Knepley 
392d700741fSMatthew G. Knepley     if (label == keys[i].label) continue;
3939566063dSJacob Faibussowitsch     if (keys[i].label) PetscCall(PetscObjectGetName((PetscObject)keys[i].label, &lname));
3949566063dSJacob Faibussowitsch     PetscCall(PetscStrcmp(name, lname, &match));
395d700741fSMatthew G. Knepley     if ((!name && !lname) || match) {
396*57d50842SBarry Smith       PetscVoidFn **funcs;
397d700741fSMatthew G. Knepley       PetscInt      Nf, j;
398d700741fSMatthew G. Knepley 
3999566063dSJacob Faibussowitsch       PetscCall(PetscWeakFormGetFunction_Private(wf, hmap, keys[i].label, keys[i].value, keys[i].field, keys[i].part, &Nf, &funcs));
400d700741fSMatthew G. Knepley       for (j = 0; j < Nf; ++j) tmpf[j] = funcs[j];
4019566063dSJacob Faibussowitsch       PetscCall(PetscWeakFormSetFunction_Private(wf, hmap, label, keys[i].value, keys[i].field, keys[i].part, Nf, tmpf));
4029566063dSJacob Faibussowitsch       PetscCall(PetscWeakFormSetFunction_Private(wf, hmap, keys[i].label, keys[i].value, keys[i].field, keys[i].part, 0, NULL));
403d700741fSMatthew G. Knepley     }
404d700741fSMatthew G. Knepley   }
4059566063dSJacob Faibussowitsch   PetscCall(PetscFree(tmpf));
4069566063dSJacob Faibussowitsch   PetscCall(PetscFree(keys));
4073ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
408d700741fSMatthew G. Knepley }
409d700741fSMatthew G. Knepley 
410cc4c1da9SBarry Smith /*@
411d700741fSMatthew G. Knepley   PetscWeakFormReplaceLabel - Change any key on a label of the same name to use the new label
412d700741fSMatthew G. Knepley 
413d700741fSMatthew G. Knepley   Not Collective
414d700741fSMatthew G. Knepley 
415d700741fSMatthew G. Knepley   Input Parameters:
416dce8aebaSBarry Smith + wf    - The original `PetscWeakForm`
417d700741fSMatthew G. Knepley - label - The label to change keys for
418d700741fSMatthew G. Knepley 
419d700741fSMatthew G. Knepley   Level: intermediate
420d700741fSMatthew G. Knepley 
421dce8aebaSBarry Smith   Note:
422dce8aebaSBarry Smith   This is used internally when meshes are modified
423dce8aebaSBarry Smith 
424dce8aebaSBarry Smith .seealso: `PetscWeakForm`, `DMLabel`, `PetscWeakFormRewriteKeys()`, `PetscWeakFormCreate()`, `PetscWeakFormDestroy()`
425d700741fSMatthew G. Knepley @*/
PetscWeakFormReplaceLabel(PetscWeakForm wf,DMLabel label)426d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormReplaceLabel(PetscWeakForm wf, DMLabel label)
427d71ae5a4SJacob Faibussowitsch {
428d700741fSMatthew G. Knepley   PetscInt f;
429d700741fSMatthew G. Knepley 
430d700741fSMatthew G. Knepley   PetscFunctionBegin;
4319566063dSJacob Faibussowitsch   for (f = 0; f < PETSC_NUM_WF; ++f) PetscCall(PetscWeakFormReplaceLabel_Internal(wf, wf->form[f], label));
4323ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
433d700741fSMatthew G. Knepley }
434d700741fSMatthew G. Knepley 
PetscWeakFormClearIndex(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt part,PetscWeakFormKind kind,PetscInt ind)435d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormClearIndex(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part, PetscWeakFormKind kind, PetscInt ind)
436d71ae5a4SJacob Faibussowitsch {
43706ad1575SMatthew G. Knepley   PetscFunctionBegin;
4389566063dSJacob Faibussowitsch   PetscCall(PetscWeakFormClearIndexFunction_Private(wf, wf->form[kind], label, val, f, part, ind));
4393ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
44006ad1575SMatthew G. Knepley }
44106ad1575SMatthew G. Knepley 
PetscWeakFormGetObjective(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt part,PetscInt * n,void (*** obj)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))442d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormGetObjective(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part, PetscInt *n, void (***obj)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
443d71ae5a4SJacob Faibussowitsch {
4446528b96dSMatthew G. Knepley   PetscFunctionBegin;
4459566063dSJacob Faibussowitsch   PetscCall(PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_OBJECTIVE], label, val, f, part, n, (void (***)(void))obj));
4463ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
4476528b96dSMatthew G. Knepley }
4486528b96dSMatthew G. Knepley 
PetscWeakFormSetObjective(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt part,PetscInt n,void (** obj)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))449d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormSetObjective(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part, PetscInt n, void (**obj)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
450d71ae5a4SJacob Faibussowitsch {
4516528b96dSMatthew G. Knepley   PetscFunctionBegin;
452*57d50842SBarry Smith   PetscCall(PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_OBJECTIVE], label, val, f, part, n, (PetscVoidFn **)obj));
4533ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
4546528b96dSMatthew G. Knepley }
4556528b96dSMatthew G. Knepley 
PetscWeakFormAddObjective(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt part,void (* obj)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))456d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormAddObjective(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part, void (*obj)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
457d71ae5a4SJacob Faibussowitsch {
4586528b96dSMatthew G. Knepley   PetscFunctionBegin;
459*57d50842SBarry Smith   PetscCall(PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_OBJECTIVE], label, val, f, part, (PetscVoidFn *)obj));
4603ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
4616528b96dSMatthew G. Knepley }
4626528b96dSMatthew G. Knepley 
PetscWeakFormGetIndexObjective(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt part,PetscInt ind,void (** obj)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))463d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormGetIndexObjective(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part, PetscInt ind, void (**obj)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
464d71ae5a4SJacob Faibussowitsch {
4656528b96dSMatthew G. Knepley   PetscFunctionBegin;
466*57d50842SBarry Smith   PetscCall(PetscWeakFormGetIndexFunction_Private(wf, wf->form[PETSC_WF_OBJECTIVE], label, val, f, part, ind, (PetscVoidFn **)obj));
4673ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
4686528b96dSMatthew G. Knepley }
4696528b96dSMatthew G. Knepley 
PetscWeakFormSetIndexObjective(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt part,PetscInt ind,void (* obj)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))470d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormSetIndexObjective(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part, PetscInt ind, void (*obj)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
471d71ae5a4SJacob Faibussowitsch {
4726528b96dSMatthew G. Knepley   PetscFunctionBegin;
473*57d50842SBarry Smith   PetscCall(PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_OBJECTIVE], label, val, f, part, ind, (PetscVoidFn *)obj));
4743ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
4756528b96dSMatthew G. Knepley }
4766528b96dSMatthew G. Knepley 
PetscWeakFormGetResidual(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt part,PetscInt * n0,void (*** f0)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt * n1,void (*** f1)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))477d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormGetResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part, PetscInt *n0, void (***f0)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt *n1, void (***f1)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
478d71ae5a4SJacob Faibussowitsch {
4796528b96dSMatthew G. Knepley   PetscFunctionBegin;
4809566063dSJacob Faibussowitsch   PetscCall(PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_F0], label, val, f, part, n0, (void (***)(void))f0));
4819566063dSJacob Faibussowitsch   PetscCall(PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_F1], label, val, f, part, n1, (void (***)(void))f1));
4823ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
4836528b96dSMatthew G. Knepley }
4846528b96dSMatthew G. Knepley 
PetscWeakFormAddResidual(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt part,void (* f0)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),void (* f1)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))485d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormAddResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part, void (*f0)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), void (*f1)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
486d71ae5a4SJacob Faibussowitsch {
4876528b96dSMatthew G. Knepley   PetscFunctionBegin;
488*57d50842SBarry Smith   PetscCall(PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_F0], label, val, f, part, (PetscVoidFn *)f0));
489*57d50842SBarry Smith   PetscCall(PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_F1], label, val, f, part, (PetscVoidFn *)f1));
4903ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
4916528b96dSMatthew G. Knepley }
4926528b96dSMatthew G. Knepley 
PetscWeakFormSetResidual(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt part,PetscInt n0,void (** f0)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt n1,void (** f1)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))493d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormSetResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part, PetscInt n0, void (**f0)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt n1, void (**f1)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
494d71ae5a4SJacob Faibussowitsch {
4956528b96dSMatthew G. Knepley   PetscFunctionBegin;
496*57d50842SBarry Smith   PetscCall(PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_F0], label, val, f, part, n0, (PetscVoidFn **)f0));
497*57d50842SBarry Smith   PetscCall(PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_F1], label, val, f, part, n1, (PetscVoidFn **)f1));
4983ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
4996528b96dSMatthew G. Knepley }
5006528b96dSMatthew G. Knepley 
PetscWeakFormSetIndexResidual(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt part,PetscInt i0,void (* f0)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt i1,void (* f1)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))501d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormSetIndexResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part, PetscInt i0, void (*f0)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt i1, void (*f1)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
502d71ae5a4SJacob Faibussowitsch {
5036528b96dSMatthew G. Knepley   PetscFunctionBegin;
504*57d50842SBarry Smith   PetscCall(PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_F0], label, val, f, part, i0, (PetscVoidFn *)f0));
505*57d50842SBarry Smith   PetscCall(PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_F1], label, val, f, part, i1, (PetscVoidFn *)f1));
5063ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
5076528b96dSMatthew G. Knepley }
5086528b96dSMatthew G. Knepley 
PetscWeakFormGetBdResidual(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt part,PetscInt * n0,void (*** f0)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt * n1,void (*** f1)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))509d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormGetBdResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part, PetscInt *n0, void (***f0)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt *n1, void (***f1)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
510d71ae5a4SJacob Faibussowitsch {
5116528b96dSMatthew G. Knepley   PetscFunctionBegin;
5129566063dSJacob Faibussowitsch   PetscCall(PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_BDF0], label, val, f, part, n0, (void (***)(void))f0));
5139566063dSJacob Faibussowitsch   PetscCall(PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_BDF1], label, val, f, part, n1, (void (***)(void))f1));
5143ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
5156528b96dSMatthew G. Knepley }
5166528b96dSMatthew G. Knepley 
PetscWeakFormAddBdResidual(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt part,void (* f0)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),void (* f1)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))517d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormAddBdResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part, void (*f0)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), void (*f1)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
518d71ae5a4SJacob Faibussowitsch {
5196528b96dSMatthew G. Knepley   PetscFunctionBegin;
520*57d50842SBarry Smith   PetscCall(PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_BDF0], label, val, f, part, (PetscVoidFn *)f0));
521*57d50842SBarry Smith   PetscCall(PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_BDF1], label, val, f, part, (PetscVoidFn *)f1));
5223ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
5236528b96dSMatthew G. Knepley }
5246528b96dSMatthew G. Knepley 
PetscWeakFormSetBdResidual(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt part,PetscInt n0,void (** f0)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt n1,void (** f1)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))525d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormSetBdResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part, PetscInt n0, void (**f0)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt n1, void (**f1)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
526d71ae5a4SJacob Faibussowitsch {
5276528b96dSMatthew G. Knepley   PetscFunctionBegin;
528*57d50842SBarry Smith   PetscCall(PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_BDF0], label, val, f, part, n0, (PetscVoidFn **)f0));
529*57d50842SBarry Smith   PetscCall(PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_BDF1], label, val, f, part, n1, (PetscVoidFn **)f1));
5303ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
5316528b96dSMatthew G. Knepley }
5326528b96dSMatthew G. Knepley 
PetscWeakFormSetIndexBdResidual(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt part,PetscInt i0,void (* f0)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt i1,void (* f1)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))533d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormSetIndexBdResidual(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part, PetscInt i0, void (*f0)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt i1, void (*f1)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
534d71ae5a4SJacob Faibussowitsch {
5356528b96dSMatthew G. Knepley   PetscFunctionBegin;
536*57d50842SBarry Smith   PetscCall(PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_BDF0], label, val, f, part, i0, (PetscVoidFn *)f0));
537*57d50842SBarry Smith   PetscCall(PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_BDF1], label, val, f, part, i1, (PetscVoidFn *)f1));
5383ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
5396528b96dSMatthew G. Knepley }
5406528b96dSMatthew G. Knepley 
PetscWeakFormHasJacobian(PetscWeakForm wf,PetscBool * hasJac)541d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormHasJacobian(PetscWeakForm wf, PetscBool *hasJac)
542d71ae5a4SJacob Faibussowitsch {
5436528b96dSMatthew G. Knepley   PetscInt n0, n1, n2, n3;
5446528b96dSMatthew G. Knepley 
5456528b96dSMatthew G. Knepley   PetscFunctionBegin;
5466528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
5474f572ea9SToby Isaac   PetscAssertPointer(hasJac, 2);
5489566063dSJacob Faibussowitsch   PetscCall(PetscHMapFormGetSize(wf->form[PETSC_WF_G0], &n0));
5499566063dSJacob Faibussowitsch   PetscCall(PetscHMapFormGetSize(wf->form[PETSC_WF_G1], &n1));
5509566063dSJacob Faibussowitsch   PetscCall(PetscHMapFormGetSize(wf->form[PETSC_WF_G2], &n2));
5519566063dSJacob Faibussowitsch   PetscCall(PetscHMapFormGetSize(wf->form[PETSC_WF_G3], &n3));
5526528b96dSMatthew G. Knepley   *hasJac = n0 + n1 + n2 + n3 ? PETSC_TRUE : PETSC_FALSE;
5533ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
5546528b96dSMatthew G. Knepley }
5556528b96dSMatthew G. Knepley 
PetscWeakFormGetJacobian(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt g,PetscInt part,PetscInt * n0,void (*** g0)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt * n1,void (*** g1)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt * n2,void (*** g2)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt * n3,void (*** g3)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))556d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormGetJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part, PetscInt *n0, void (***g0)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt *n1, void (***g1)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt *n2, void (***g2)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt *n3, void (***g3)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
557d71ae5a4SJacob Faibussowitsch {
5586528b96dSMatthew G. Knepley   PetscInt find = f * wf->Nf + g;
5596528b96dSMatthew G. Knepley 
5606528b96dSMatthew G. Knepley   PetscFunctionBegin;
5619566063dSJacob Faibussowitsch   PetscCall(PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_G0], label, val, find, part, n0, (void (***)(void))g0));
5629566063dSJacob Faibussowitsch   PetscCall(PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_G1], label, val, find, part, n1, (void (***)(void))g1));
5639566063dSJacob Faibussowitsch   PetscCall(PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_G2], label, val, find, part, n2, (void (***)(void))g2));
5649566063dSJacob Faibussowitsch   PetscCall(PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_G3], label, val, find, part, n3, (void (***)(void))g3));
5653ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
5666528b96dSMatthew G. Knepley }
5676528b96dSMatthew G. Knepley 
PetscWeakFormAddJacobian(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt g,PetscInt part,void (* g0)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),void (* g1)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),void (* g2)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),void (* g3)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))568d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormAddJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part, void (*g0)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), void (*g1)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), void (*g2)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), void (*g3)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
569d71ae5a4SJacob Faibussowitsch {
5706528b96dSMatthew G. Knepley   PetscInt find = f * wf->Nf + g;
5716528b96dSMatthew G. Knepley 
5726528b96dSMatthew G. Knepley   PetscFunctionBegin;
573*57d50842SBarry Smith   PetscCall(PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_G0], label, val, find, part, (PetscVoidFn *)g0));
574*57d50842SBarry Smith   PetscCall(PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_G1], label, val, find, part, (PetscVoidFn *)g1));
575*57d50842SBarry Smith   PetscCall(PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_G2], label, val, find, part, (PetscVoidFn *)g2));
576*57d50842SBarry Smith   PetscCall(PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_G3], label, val, find, part, (PetscVoidFn *)g3));
5773ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
5786528b96dSMatthew G. Knepley }
5796528b96dSMatthew G. Knepley 
PetscWeakFormSetJacobian(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt g,PetscInt part,PetscInt n0,void (** g0)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt n1,void (** g1)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt n2,void (** g2)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt n3,void (** g3)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))580d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormSetJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part, PetscInt n0, void (**g0)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt n1, void (**g1)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt n2, void (**g2)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt n3, void (**g3)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
581d71ae5a4SJacob Faibussowitsch {
5826528b96dSMatthew G. Knepley   PetscInt find = f * wf->Nf + g;
5836528b96dSMatthew G. Knepley 
5846528b96dSMatthew G. Knepley   PetscFunctionBegin;
585*57d50842SBarry Smith   PetscCall(PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_G0], label, val, find, part, n0, (PetscVoidFn **)g0));
586*57d50842SBarry Smith   PetscCall(PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_G1], label, val, find, part, n1, (PetscVoidFn **)g1));
587*57d50842SBarry Smith   PetscCall(PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_G2], label, val, find, part, n2, (PetscVoidFn **)g2));
588*57d50842SBarry Smith   PetscCall(PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_G3], label, val, find, part, n3, (PetscVoidFn **)g3));
5893ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
5906528b96dSMatthew G. Knepley }
5916528b96dSMatthew G. Knepley 
PetscWeakFormSetIndexJacobian(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt g,PetscInt part,PetscInt i0,void (* g0)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt i1,void (* g1)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt i2,void (* g2)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt i3,void (* g3)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))592d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormSetIndexJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part, PetscInt i0, void (*g0)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt i1, void (*g1)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt i2, void (*g2)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt i3, void (*g3)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
593d71ae5a4SJacob Faibussowitsch {
5946528b96dSMatthew G. Knepley   PetscInt find = f * wf->Nf + g;
5956528b96dSMatthew G. Knepley 
5966528b96dSMatthew G. Knepley   PetscFunctionBegin;
597*57d50842SBarry Smith   PetscCall(PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_G0], label, val, find, part, i0, (PetscVoidFn *)g0));
598*57d50842SBarry Smith   PetscCall(PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_G1], label, val, find, part, i1, (PetscVoidFn *)g1));
599*57d50842SBarry Smith   PetscCall(PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_G2], label, val, find, part, i2, (PetscVoidFn *)g2));
600*57d50842SBarry Smith   PetscCall(PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_G3], label, val, find, part, i3, (PetscVoidFn *)g3));
6013ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
6026528b96dSMatthew G. Knepley }
6036528b96dSMatthew G. Knepley 
PetscWeakFormHasJacobianPreconditioner(PetscWeakForm wf,PetscBool * hasJacPre)604d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormHasJacobianPreconditioner(PetscWeakForm wf, PetscBool *hasJacPre)
605d71ae5a4SJacob Faibussowitsch {
6066528b96dSMatthew G. Knepley   PetscInt n0, n1, n2, n3;
6076528b96dSMatthew G. Knepley 
6086528b96dSMatthew G. Knepley   PetscFunctionBegin;
6096528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
6104f572ea9SToby Isaac   PetscAssertPointer(hasJacPre, 2);
6119566063dSJacob Faibussowitsch   PetscCall(PetscHMapFormGetSize(wf->form[PETSC_WF_GP0], &n0));
6129566063dSJacob Faibussowitsch   PetscCall(PetscHMapFormGetSize(wf->form[PETSC_WF_GP1], &n1));
6139566063dSJacob Faibussowitsch   PetscCall(PetscHMapFormGetSize(wf->form[PETSC_WF_GP2], &n2));
6149566063dSJacob Faibussowitsch   PetscCall(PetscHMapFormGetSize(wf->form[PETSC_WF_GP3], &n3));
6156528b96dSMatthew G. Knepley   *hasJacPre = n0 + n1 + n2 + n3 ? PETSC_TRUE : PETSC_FALSE;
6163ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
6176528b96dSMatthew G. Knepley }
6186528b96dSMatthew G. Knepley 
PetscWeakFormGetJacobianPreconditioner(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt g,PetscInt part,PetscInt * n0,void (*** g0)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt * n1,void (*** g1)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt * n2,void (*** g2)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt * n3,void (*** g3)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))619d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormGetJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part, PetscInt *n0, void (***g0)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt *n1, void (***g1)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt *n2, void (***g2)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt *n3, void (***g3)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
620d71ae5a4SJacob Faibussowitsch {
6216528b96dSMatthew G. Knepley   PetscInt find = f * wf->Nf + g;
6226528b96dSMatthew G. Knepley 
6236528b96dSMatthew G. Knepley   PetscFunctionBegin;
6249566063dSJacob Faibussowitsch   PetscCall(PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_GP0], label, val, find, part, n0, (void (***)(void))g0));
6259566063dSJacob Faibussowitsch   PetscCall(PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_GP1], label, val, find, part, n1, (void (***)(void))g1));
6269566063dSJacob Faibussowitsch   PetscCall(PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_GP2], label, val, find, part, n2, (void (***)(void))g2));
6279566063dSJacob Faibussowitsch   PetscCall(PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_GP3], label, val, find, part, n3, (void (***)(void))g3));
6283ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
6296528b96dSMatthew G. Knepley }
6306528b96dSMatthew G. Knepley 
PetscWeakFormAddJacobianPreconditioner(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt g,PetscInt part,void (* g0)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),void (* g1)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),void (* g2)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),void (* g3)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))631d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormAddJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part, void (*g0)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), void (*g1)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), void (*g2)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), void (*g3)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
632d71ae5a4SJacob Faibussowitsch {
6336528b96dSMatthew G. Knepley   PetscInt find = f * wf->Nf + g;
6346528b96dSMatthew G. Knepley 
6356528b96dSMatthew G. Knepley   PetscFunctionBegin;
636*57d50842SBarry Smith   PetscCall(PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_GP0], label, val, find, part, (PetscVoidFn *)g0));
637*57d50842SBarry Smith   PetscCall(PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_GP1], label, val, find, part, (PetscVoidFn *)g1));
638*57d50842SBarry Smith   PetscCall(PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_GP2], label, val, find, part, (PetscVoidFn *)g2));
639*57d50842SBarry Smith   PetscCall(PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_GP3], label, val, find, part, (PetscVoidFn *)g3));
6403ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
6416528b96dSMatthew G. Knepley }
6426528b96dSMatthew G. Knepley 
PetscWeakFormSetJacobianPreconditioner(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt g,PetscInt part,PetscInt n0,void (** g0)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt n1,void (** g1)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt n2,void (** g2)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt n3,void (** g3)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))643d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormSetJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part, PetscInt n0, void (**g0)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt n1, void (**g1)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt n2, void (**g2)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt n3, void (**g3)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
644d71ae5a4SJacob Faibussowitsch {
6456528b96dSMatthew G. Knepley   PetscInt find = f * wf->Nf + g;
6466528b96dSMatthew G. Knepley 
6476528b96dSMatthew G. Knepley   PetscFunctionBegin;
648*57d50842SBarry Smith   PetscCall(PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_GP0], label, val, find, part, n0, (PetscVoidFn **)g0));
649*57d50842SBarry Smith   PetscCall(PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_GP1], label, val, find, part, n1, (PetscVoidFn **)g1));
650*57d50842SBarry Smith   PetscCall(PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_GP2], label, val, find, part, n2, (PetscVoidFn **)g2));
651*57d50842SBarry Smith   PetscCall(PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_GP3], label, val, find, part, n3, (PetscVoidFn **)g3));
6523ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
6536528b96dSMatthew G. Knepley }
6546528b96dSMatthew G. Knepley 
PetscWeakFormSetIndexJacobianPreconditioner(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt g,PetscInt part,PetscInt i0,void (* g0)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt i1,void (* g1)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt i2,void (* g2)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt i3,void (* g3)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))655d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormSetIndexJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part, PetscInt i0, void (*g0)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt i1, void (*g1)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt i2, void (*g2)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt i3, void (*g3)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
656d71ae5a4SJacob Faibussowitsch {
6576528b96dSMatthew G. Knepley   PetscInt find = f * wf->Nf + g;
6586528b96dSMatthew G. Knepley 
6596528b96dSMatthew G. Knepley   PetscFunctionBegin;
660*57d50842SBarry Smith   PetscCall(PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_GP0], label, val, find, part, i0, (PetscVoidFn *)g0));
661*57d50842SBarry Smith   PetscCall(PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_GP1], label, val, find, part, i1, (PetscVoidFn *)g1));
662*57d50842SBarry Smith   PetscCall(PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_GP2], label, val, find, part, i2, (PetscVoidFn *)g2));
663*57d50842SBarry Smith   PetscCall(PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_GP3], label, val, find, part, i3, (PetscVoidFn *)g3));
6643ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
6656528b96dSMatthew G. Knepley }
6666528b96dSMatthew G. Knepley 
PetscWeakFormHasBdJacobian(PetscWeakForm wf,PetscBool * hasJac)667d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormHasBdJacobian(PetscWeakForm wf, PetscBool *hasJac)
668d71ae5a4SJacob Faibussowitsch {
6696528b96dSMatthew G. Knepley   PetscInt n0, n1, n2, n3;
6706528b96dSMatthew G. Knepley 
6716528b96dSMatthew G. Knepley   PetscFunctionBegin;
6726528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
6734f572ea9SToby Isaac   PetscAssertPointer(hasJac, 2);
6749566063dSJacob Faibussowitsch   PetscCall(PetscHMapFormGetSize(wf->form[PETSC_WF_BDG0], &n0));
6759566063dSJacob Faibussowitsch   PetscCall(PetscHMapFormGetSize(wf->form[PETSC_WF_BDG1], &n1));
6769566063dSJacob Faibussowitsch   PetscCall(PetscHMapFormGetSize(wf->form[PETSC_WF_BDG2], &n2));
6779566063dSJacob Faibussowitsch   PetscCall(PetscHMapFormGetSize(wf->form[PETSC_WF_BDG3], &n3));
6786528b96dSMatthew G. Knepley   *hasJac = n0 + n1 + n2 + n3 ? PETSC_TRUE : PETSC_FALSE;
6793ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
6806528b96dSMatthew G. Knepley }
6816528b96dSMatthew G. Knepley 
PetscWeakFormGetBdJacobian(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt g,PetscInt part,PetscInt * n0,void (*** g0)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt * n1,void (*** g1)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt * n2,void (*** g2)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt * n3,void (*** g3)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))682d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormGetBdJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part, PetscInt *n0, void (***g0)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt *n1, void (***g1)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt *n2, void (***g2)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt *n3, void (***g3)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
683d71ae5a4SJacob Faibussowitsch {
6846528b96dSMatthew G. Knepley   PetscInt find = f * wf->Nf + g;
6856528b96dSMatthew G. Knepley 
6866528b96dSMatthew G. Knepley   PetscFunctionBegin;
6879566063dSJacob Faibussowitsch   PetscCall(PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_BDG0], label, val, find, part, n0, (void (***)(void))g0));
6889566063dSJacob Faibussowitsch   PetscCall(PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_BDG1], label, val, find, part, n1, (void (***)(void))g1));
6899566063dSJacob Faibussowitsch   PetscCall(PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_BDG2], label, val, find, part, n2, (void (***)(void))g2));
6909566063dSJacob Faibussowitsch   PetscCall(PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_BDG3], label, val, find, part, n3, (void (***)(void))g3));
6913ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
6926528b96dSMatthew G. Knepley }
6936528b96dSMatthew G. Knepley 
PetscWeakFormAddBdJacobian(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt g,PetscInt part,void (* g0)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),void (* g1)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),void (* g2)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),void (* g3)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))694d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormAddBdJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part, void (*g0)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), void (*g1)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), void (*g2)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), void (*g3)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
695d71ae5a4SJacob Faibussowitsch {
6966528b96dSMatthew G. Knepley   PetscInt find = f * wf->Nf + g;
6976528b96dSMatthew G. Knepley 
6986528b96dSMatthew G. Knepley   PetscFunctionBegin;
699*57d50842SBarry Smith   PetscCall(PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_BDG0], label, val, find, part, (PetscVoidFn *)g0));
700*57d50842SBarry Smith   PetscCall(PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_BDG1], label, val, find, part, (PetscVoidFn *)g1));
701*57d50842SBarry Smith   PetscCall(PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_BDG2], label, val, find, part, (PetscVoidFn *)g2));
702*57d50842SBarry Smith   PetscCall(PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_BDG3], label, val, find, part, (PetscVoidFn *)g3));
7033ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
7046528b96dSMatthew G. Knepley }
7056528b96dSMatthew G. Knepley 
PetscWeakFormSetBdJacobian(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt g,PetscInt part,PetscInt n0,void (** g0)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt n1,void (** g1)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt n2,void (** g2)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt n3,void (** g3)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))706d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormSetBdJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part, PetscInt n0, void (**g0)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt n1, void (**g1)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt n2, void (**g2)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt n3, void (**g3)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
707d71ae5a4SJacob Faibussowitsch {
7086528b96dSMatthew G. Knepley   PetscInt find = f * wf->Nf + g;
7096528b96dSMatthew G. Knepley 
7106528b96dSMatthew G. Knepley   PetscFunctionBegin;
711*57d50842SBarry Smith   PetscCall(PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_BDG0], label, val, find, part, n0, (PetscVoidFn **)g0));
712*57d50842SBarry Smith   PetscCall(PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_BDG1], label, val, find, part, n1, (PetscVoidFn **)g1));
713*57d50842SBarry Smith   PetscCall(PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_BDG2], label, val, find, part, n2, (PetscVoidFn **)g2));
714*57d50842SBarry Smith   PetscCall(PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_BDG3], label, val, find, part, n3, (PetscVoidFn **)g3));
7153ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
7166528b96dSMatthew G. Knepley }
7176528b96dSMatthew G. Knepley 
PetscWeakFormSetIndexBdJacobian(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt g,PetscInt part,PetscInt i0,void (* g0)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt i1,void (* g1)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt i2,void (* g2)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt i3,void (* g3)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))718d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormSetIndexBdJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part, PetscInt i0, void (*g0)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt i1, void (*g1)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt i2, void (*g2)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt i3, void (*g3)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
719d71ae5a4SJacob Faibussowitsch {
7206528b96dSMatthew G. Knepley   PetscInt find = f * wf->Nf + g;
7216528b96dSMatthew G. Knepley 
7226528b96dSMatthew G. Knepley   PetscFunctionBegin;
723*57d50842SBarry Smith   PetscCall(PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_BDG0], label, val, find, part, i0, (PetscVoidFn *)g0));
724*57d50842SBarry Smith   PetscCall(PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_BDG1], label, val, find, part, i1, (PetscVoidFn *)g1));
725*57d50842SBarry Smith   PetscCall(PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_BDG2], label, val, find, part, i2, (PetscVoidFn *)g2));
726*57d50842SBarry Smith   PetscCall(PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_BDG3], label, val, find, part, i3, (PetscVoidFn *)g3));
7273ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
7286528b96dSMatthew G. Knepley }
7296528b96dSMatthew G. Knepley 
PetscWeakFormHasBdJacobianPreconditioner(PetscWeakForm wf,PetscBool * hasJacPre)730d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormHasBdJacobianPreconditioner(PetscWeakForm wf, PetscBool *hasJacPre)
731d71ae5a4SJacob Faibussowitsch {
7326528b96dSMatthew G. Knepley   PetscInt n0, n1, n2, n3;
7336528b96dSMatthew G. Knepley 
7346528b96dSMatthew G. Knepley   PetscFunctionBegin;
7356528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
7364f572ea9SToby Isaac   PetscAssertPointer(hasJacPre, 2);
7379566063dSJacob Faibussowitsch   PetscCall(PetscHMapFormGetSize(wf->form[PETSC_WF_BDGP0], &n0));
7389566063dSJacob Faibussowitsch   PetscCall(PetscHMapFormGetSize(wf->form[PETSC_WF_BDGP1], &n1));
7399566063dSJacob Faibussowitsch   PetscCall(PetscHMapFormGetSize(wf->form[PETSC_WF_BDGP2], &n2));
7409566063dSJacob Faibussowitsch   PetscCall(PetscHMapFormGetSize(wf->form[PETSC_WF_BDGP3], &n3));
7416528b96dSMatthew G. Knepley   *hasJacPre = n0 + n1 + n2 + n3 ? PETSC_TRUE : PETSC_FALSE;
7423ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
7436528b96dSMatthew G. Knepley }
7446528b96dSMatthew G. Knepley 
PetscWeakFormGetBdJacobianPreconditioner(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt g,PetscInt part,PetscInt * n0,void (*** g0)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt * n1,void (*** g1)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt * n2,void (*** g2)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt * n3,void (*** g3)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))745d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormGetBdJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part, PetscInt *n0, void (***g0)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt *n1, void (***g1)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt *n2, void (***g2)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt *n3, void (***g3)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
746d71ae5a4SJacob Faibussowitsch {
7476528b96dSMatthew G. Knepley   PetscInt find = f * wf->Nf + g;
7486528b96dSMatthew G. Knepley 
7496528b96dSMatthew G. Knepley   PetscFunctionBegin;
7509566063dSJacob Faibussowitsch   PetscCall(PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_BDGP0], label, val, find, part, n0, (void (***)(void))g0));
7519566063dSJacob Faibussowitsch   PetscCall(PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_BDGP1], label, val, find, part, n1, (void (***)(void))g1));
7529566063dSJacob Faibussowitsch   PetscCall(PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_BDGP2], label, val, find, part, n2, (void (***)(void))g2));
7539566063dSJacob Faibussowitsch   PetscCall(PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_BDGP3], label, val, find, part, n3, (void (***)(void))g3));
7543ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
7556528b96dSMatthew G. Knepley }
7566528b96dSMatthew G. Knepley 
PetscWeakFormAddBdJacobianPreconditioner(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt g,PetscInt part,void (* g0)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),void (* g1)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),void (* g2)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),void (* g3)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))757d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormAddBdJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part, void (*g0)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), void (*g1)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), void (*g2)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), void (*g3)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
758d71ae5a4SJacob Faibussowitsch {
7596528b96dSMatthew G. Knepley   PetscInt find = f * wf->Nf + g;
7606528b96dSMatthew G. Knepley 
7616528b96dSMatthew G. Knepley   PetscFunctionBegin;
762*57d50842SBarry Smith   PetscCall(PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_BDGP0], label, val, find, part, (PetscVoidFn *)g0));
763*57d50842SBarry Smith   PetscCall(PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_BDGP1], label, val, find, part, (PetscVoidFn *)g1));
764*57d50842SBarry Smith   PetscCall(PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_BDGP2], label, val, find, part, (PetscVoidFn *)g2));
765*57d50842SBarry Smith   PetscCall(PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_BDGP3], label, val, find, part, (PetscVoidFn *)g3));
7663ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
7676528b96dSMatthew G. Knepley }
7686528b96dSMatthew G. Knepley 
PetscWeakFormSetBdJacobianPreconditioner(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt g,PetscInt part,PetscInt n0,void (** g0)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt n1,void (** g1)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt n2,void (** g2)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt n3,void (** g3)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))769d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormSetBdJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part, PetscInt n0, void (**g0)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt n1, void (**g1)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt n2, void (**g2)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt n3, void (**g3)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
770d71ae5a4SJacob Faibussowitsch {
7716528b96dSMatthew G. Knepley   PetscInt find = f * wf->Nf + g;
7726528b96dSMatthew G. Knepley 
7736528b96dSMatthew G. Knepley   PetscFunctionBegin;
774*57d50842SBarry Smith   PetscCall(PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_BDGP0], label, val, find, part, n0, (PetscVoidFn **)g0));
775*57d50842SBarry Smith   PetscCall(PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_BDGP1], label, val, find, part, n1, (PetscVoidFn **)g1));
776*57d50842SBarry Smith   PetscCall(PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_BDGP2], label, val, find, part, n2, (PetscVoidFn **)g2));
777*57d50842SBarry Smith   PetscCall(PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_BDGP3], label, val, find, part, n3, (PetscVoidFn **)g3));
7783ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
7796528b96dSMatthew G. Knepley }
7806528b96dSMatthew G. Knepley 
PetscWeakFormSetIndexBdJacobianPreconditioner(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt g,PetscInt part,PetscInt i0,void (* g0)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt i1,void (* g1)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt i2,void (* g2)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt i3,void (* g3)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))781d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormSetIndexBdJacobianPreconditioner(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part, PetscInt i0, void (*g0)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt i1, void (*g1)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt i2, void (*g2)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt i3, void (*g3)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
782d71ae5a4SJacob Faibussowitsch {
7836528b96dSMatthew G. Knepley   PetscInt find = f * wf->Nf + g;
7846528b96dSMatthew G. Knepley 
7856528b96dSMatthew G. Knepley   PetscFunctionBegin;
786*57d50842SBarry Smith   PetscCall(PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_BDGP0], label, val, find, part, i0, (PetscVoidFn *)g0));
787*57d50842SBarry Smith   PetscCall(PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_BDGP1], label, val, find, part, i1, (PetscVoidFn *)g1));
788*57d50842SBarry Smith   PetscCall(PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_BDGP2], label, val, find, part, i2, (PetscVoidFn *)g2));
789*57d50842SBarry Smith   PetscCall(PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_BDGP3], label, val, find, part, i3, (PetscVoidFn *)g3));
7903ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
7916528b96dSMatthew G. Knepley }
7926528b96dSMatthew G. Knepley 
PetscWeakFormHasDynamicJacobian(PetscWeakForm wf,PetscBool * hasDynJac)793d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormHasDynamicJacobian(PetscWeakForm wf, PetscBool *hasDynJac)
794d71ae5a4SJacob Faibussowitsch {
7956528b96dSMatthew G. Knepley   PetscInt n0, n1, n2, n3;
7966528b96dSMatthew G. Knepley 
7976528b96dSMatthew G. Knepley   PetscFunctionBegin;
7986528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
7994f572ea9SToby Isaac   PetscAssertPointer(hasDynJac, 2);
8009566063dSJacob Faibussowitsch   PetscCall(PetscHMapFormGetSize(wf->form[PETSC_WF_GT0], &n0));
8019566063dSJacob Faibussowitsch   PetscCall(PetscHMapFormGetSize(wf->form[PETSC_WF_GT1], &n1));
8029566063dSJacob Faibussowitsch   PetscCall(PetscHMapFormGetSize(wf->form[PETSC_WF_GT2], &n2));
8039566063dSJacob Faibussowitsch   PetscCall(PetscHMapFormGetSize(wf->form[PETSC_WF_GT3], &n3));
8046528b96dSMatthew G. Knepley   *hasDynJac = n0 + n1 + n2 + n3 ? PETSC_TRUE : PETSC_FALSE;
8053ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
8066528b96dSMatthew G. Knepley }
8076528b96dSMatthew G. Knepley 
PetscWeakFormGetDynamicJacobian(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt g,PetscInt part,PetscInt * n0,void (*** g0)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt * n1,void (*** g1)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt * n2,void (*** g2)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt * n3,void (*** g3)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))808d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormGetDynamicJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part, PetscInt *n0, void (***g0)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt *n1, void (***g1)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt *n2, void (***g2)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt *n3, void (***g3)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
809d71ae5a4SJacob Faibussowitsch {
8106528b96dSMatthew G. Knepley   PetscInt find = f * wf->Nf + g;
8116528b96dSMatthew G. Knepley 
8126528b96dSMatthew G. Knepley   PetscFunctionBegin;
8139566063dSJacob Faibussowitsch   PetscCall(PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_GT0], label, val, find, part, n0, (void (***)(void))g0));
8149566063dSJacob Faibussowitsch   PetscCall(PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_GT1], label, val, find, part, n1, (void (***)(void))g1));
8159566063dSJacob Faibussowitsch   PetscCall(PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_GT2], label, val, find, part, n2, (void (***)(void))g2));
8169566063dSJacob Faibussowitsch   PetscCall(PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_GT3], label, val, find, part, n3, (void (***)(void))g3));
8173ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
8186528b96dSMatthew G. Knepley }
8196528b96dSMatthew G. Knepley 
PetscWeakFormAddDynamicJacobian(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt g,PetscInt part,void (* g0)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),void (* g1)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),void (* g2)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),void (* g3)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))820d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormAddDynamicJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part, void (*g0)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), void (*g1)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), void (*g2)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), void (*g3)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
821d71ae5a4SJacob Faibussowitsch {
8226528b96dSMatthew G. Knepley   PetscInt find = f * wf->Nf + g;
8236528b96dSMatthew G. Knepley 
8246528b96dSMatthew G. Knepley   PetscFunctionBegin;
825*57d50842SBarry Smith   PetscCall(PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_GT0], label, val, find, part, (PetscVoidFn *)g0));
826*57d50842SBarry Smith   PetscCall(PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_GT1], label, val, find, part, (PetscVoidFn *)g1));
827*57d50842SBarry Smith   PetscCall(PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_GT2], label, val, find, part, (PetscVoidFn *)g2));
828*57d50842SBarry Smith   PetscCall(PetscWeakFormAddFunction_Private(wf, wf->form[PETSC_WF_GT3], label, val, find, part, (PetscVoidFn *)g3));
8293ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
8306528b96dSMatthew G. Knepley }
8316528b96dSMatthew G. Knepley 
PetscWeakFormSetDynamicJacobian(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt g,PetscInt part,PetscInt n0,void (** g0)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt n1,void (** g1)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt n2,void (** g2)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt n3,void (** g3)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))832d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormSetDynamicJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part, PetscInt n0, void (**g0)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt n1, void (**g1)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt n2, void (**g2)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt n3, void (**g3)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
833d71ae5a4SJacob Faibussowitsch {
8346528b96dSMatthew G. Knepley   PetscInt find = f * wf->Nf + g;
8356528b96dSMatthew G. Knepley 
8366528b96dSMatthew G. Knepley   PetscFunctionBegin;
837*57d50842SBarry Smith   PetscCall(PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_GT0], label, val, find, part, n0, (PetscVoidFn **)g0));
838*57d50842SBarry Smith   PetscCall(PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_GT1], label, val, find, part, n1, (PetscVoidFn **)g1));
839*57d50842SBarry Smith   PetscCall(PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_GT2], label, val, find, part, n2, (PetscVoidFn **)g2));
840*57d50842SBarry Smith   PetscCall(PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_GT3], label, val, find, part, n3, (PetscVoidFn **)g3));
8413ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
8426528b96dSMatthew G. Knepley }
8436528b96dSMatthew G. Knepley 
PetscWeakFormSetIndexDynamicJacobian(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt g,PetscInt part,PetscInt i0,void (* g0)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt i1,void (* g1)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt i2,void (* g2)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),PetscInt i3,void (* g3)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]))844d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormSetIndexDynamicJacobian(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt g, PetscInt part, PetscInt i0, void (*g0)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt i1, void (*g1)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt i2, void (*g2)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]), PetscInt i3, void (*g3)(PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[], PetscReal, PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]))
845d71ae5a4SJacob Faibussowitsch {
8466528b96dSMatthew G. Knepley   PetscInt find = f * wf->Nf + g;
8476528b96dSMatthew G. Knepley 
8486528b96dSMatthew G. Knepley   PetscFunctionBegin;
849*57d50842SBarry Smith   PetscCall(PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_GT0], label, val, find, part, i0, (PetscVoidFn *)g0));
850*57d50842SBarry Smith   PetscCall(PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_GT1], label, val, find, part, i1, (PetscVoidFn *)g1));
851*57d50842SBarry Smith   PetscCall(PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_GT2], label, val, find, part, i2, (PetscVoidFn *)g2));
852*57d50842SBarry Smith   PetscCall(PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_GT3], label, val, find, part, i3, (PetscVoidFn *)g3));
8533ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
8546528b96dSMatthew G. Knepley }
8556528b96dSMatthew G. Knepley 
PetscWeakFormGetRiemannSolver(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt part,PetscInt * n,void (*** r)(PetscInt,PetscInt,const PetscReal[],const PetscReal[],const PetscScalar[],const PetscScalar[],PetscInt,const PetscScalar[],PetscScalar[],void *))856d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormGetRiemannSolver(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part, PetscInt *n, void (***r)(PetscInt, PetscInt, const PetscReal[], const PetscReal[], const PetscScalar[], const PetscScalar[], PetscInt, const PetscScalar[], PetscScalar[], void *))
857d71ae5a4SJacob Faibussowitsch {
8586528b96dSMatthew G. Knepley   PetscFunctionBegin;
8599566063dSJacob Faibussowitsch   PetscCall(PetscWeakFormGetFunction_Private(wf, wf->form[PETSC_WF_R], label, val, f, part, n, (void (***)(void))r));
8603ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
8616528b96dSMatthew G. Knepley }
8626528b96dSMatthew G. Knepley 
PetscWeakFormSetRiemannSolver(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt part,PetscInt n,void (** r)(PetscInt,PetscInt,const PetscReal[],const PetscReal[],const PetscScalar[],const PetscScalar[],PetscInt,const PetscScalar[],PetscScalar[],void *))863d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormSetRiemannSolver(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part, PetscInt n, void (**r)(PetscInt, PetscInt, const PetscReal[], const PetscReal[], const PetscScalar[], const PetscScalar[], PetscInt, const PetscScalar[], PetscScalar[], void *))
864d71ae5a4SJacob Faibussowitsch {
8656528b96dSMatthew G. Knepley   PetscFunctionBegin;
866*57d50842SBarry Smith   PetscCall(PetscWeakFormSetFunction_Private(wf, wf->form[PETSC_WF_R], label, val, f, part, n, (PetscVoidFn **)r));
8673ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
8686528b96dSMatthew G. Knepley }
8696528b96dSMatthew G. Knepley 
PetscWeakFormSetIndexRiemannSolver(PetscWeakForm wf,DMLabel label,PetscInt val,PetscInt f,PetscInt part,PetscInt i,void (* r)(PetscInt,PetscInt,const PetscReal[],const PetscReal[],const PetscScalar[],const PetscScalar[],PetscInt,const PetscScalar[],PetscScalar[],void *))870d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormSetIndexRiemannSolver(PetscWeakForm wf, DMLabel label, PetscInt val, PetscInt f, PetscInt part, PetscInt i, void (*r)(PetscInt, PetscInt, const PetscReal[], const PetscReal[], const PetscScalar[], const PetscScalar[], PetscInt, const PetscScalar[], PetscScalar[], void *))
871d71ae5a4SJacob Faibussowitsch {
8726528b96dSMatthew G. Knepley   PetscFunctionBegin;
873*57d50842SBarry Smith   PetscCall(PetscWeakFormSetIndexFunction_Private(wf, wf->form[PETSC_WF_R], label, val, f, part, i, (PetscVoidFn *)r));
8743ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
8756528b96dSMatthew G. Knepley }
8766528b96dSMatthew G. Knepley 
8776528b96dSMatthew G. Knepley /*@
878dce8aebaSBarry Smith   PetscWeakFormGetNumFields - Returns the number of fields in a `PetscWeakForm`
8796528b96dSMatthew G. Knepley 
88020f4b53cSBarry Smith   Not Collective
8816528b96dSMatthew G. Knepley 
8826528b96dSMatthew G. Knepley   Input Parameter:
883dce8aebaSBarry Smith . wf - The `PetscWeakForm` object
8846528b96dSMatthew G. Knepley 
8856528b96dSMatthew G. Knepley   Output Parameter:
886a5b23f4aSJose E. Roman . Nf - The number of fields
8876528b96dSMatthew G. Knepley 
8886528b96dSMatthew G. Knepley   Level: beginner
8896528b96dSMatthew G. Knepley 
890dce8aebaSBarry Smith .seealso: `PetscWeakForm`, `PetscWeakFormSetNumFields()`, `PetscWeakFormCreate()`
8916528b96dSMatthew G. Knepley @*/
PetscWeakFormGetNumFields(PetscWeakForm wf,PetscInt * Nf)892d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormGetNumFields(PetscWeakForm wf, PetscInt *Nf)
893d71ae5a4SJacob Faibussowitsch {
8946528b96dSMatthew G. Knepley   PetscFunctionBegin;
8956528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
8964f572ea9SToby Isaac   PetscAssertPointer(Nf, 2);
8976528b96dSMatthew G. Knepley   *Nf = wf->Nf;
8983ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
8996528b96dSMatthew G. Knepley }
9006528b96dSMatthew G. Knepley 
9016528b96dSMatthew G. Knepley /*@
9026528b96dSMatthew G. Knepley   PetscWeakFormSetNumFields - Sets the number of fields
9036528b96dSMatthew G. Knepley 
90420f4b53cSBarry Smith   Not Collective
9056528b96dSMatthew G. Knepley 
9066528b96dSMatthew G. Knepley   Input Parameters:
907dce8aebaSBarry Smith + wf - The `PetscWeakForm` object
9086528b96dSMatthew G. Knepley - Nf - The number of fields
9096528b96dSMatthew G. Knepley 
9106528b96dSMatthew G. Knepley   Level: beginner
9116528b96dSMatthew G. Knepley 
912dce8aebaSBarry Smith .seealso: `PetscWeakForm`, `PetscWeakFormGetNumFields()`, `PetscWeakFormCreate()`
9136528b96dSMatthew G. Knepley @*/
PetscWeakFormSetNumFields(PetscWeakForm wf,PetscInt Nf)914d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormSetNumFields(PetscWeakForm wf, PetscInt Nf)
915d71ae5a4SJacob Faibussowitsch {
9166528b96dSMatthew G. Knepley   PetscFunctionBegin;
9176528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
9186528b96dSMatthew G. Knepley   wf->Nf = Nf;
9193ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
9206528b96dSMatthew G. Knepley }
9216528b96dSMatthew G. Knepley 
9226528b96dSMatthew G. Knepley /*@
923dce8aebaSBarry Smith   PetscWeakFormDestroy - Destroys a `PetscWeakForm` object
9246528b96dSMatthew G. Knepley 
92520f4b53cSBarry Smith   Collective
9266528b96dSMatthew G. Knepley 
9276528b96dSMatthew G. Knepley   Input Parameter:
928dce8aebaSBarry Smith . wf - the `PetscWeakForm` object to destroy
9296528b96dSMatthew G. Knepley 
9306528b96dSMatthew G. Knepley   Level: developer
9316528b96dSMatthew G. Knepley 
932dce8aebaSBarry Smith .seealso: `PetscWeakForm`, `PetscWeakFormCreate()`, `PetscWeakFormView()`
9336528b96dSMatthew G. Knepley @*/
PetscWeakFormDestroy(PetscWeakForm * wf)934d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormDestroy(PetscWeakForm *wf)
935d71ae5a4SJacob Faibussowitsch {
93606ad1575SMatthew G. Knepley   PetscInt f;
9376528b96dSMatthew G. Knepley 
9386528b96dSMatthew G. Knepley   PetscFunctionBegin;
9393ba16761SJacob Faibussowitsch   if (!*wf) PetscFunctionReturn(PETSC_SUCCESS);
940f4f49eeaSPierre Jolivet   PetscValidHeaderSpecific(*wf, PETSCWEAKFORM_CLASSID, 1);
9416528b96dSMatthew G. Knepley 
942f4f49eeaSPierre Jolivet   if (--((PetscObject)*wf)->refct > 0) {
9439371c9d4SSatish Balay     *wf = NULL;
9443ba16761SJacob Faibussowitsch     PetscFunctionReturn(PETSC_SUCCESS);
9459371c9d4SSatish Balay   }
946f4f49eeaSPierre Jolivet   ((PetscObject)*wf)->refct = 0;
9479566063dSJacob Faibussowitsch   PetscCall(PetscChunkBufferDestroy(&(*wf)->funcs));
9489566063dSJacob Faibussowitsch   for (f = 0; f < PETSC_NUM_WF; ++f) PetscCall(PetscHMapFormDestroy(&(*wf)->form[f]));
9499566063dSJacob Faibussowitsch   PetscCall(PetscFree((*wf)->form));
9509566063dSJacob Faibussowitsch   PetscCall(PetscHeaderDestroy(wf));
9513ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
9526528b96dSMatthew G. Knepley }
9536528b96dSMatthew G. Knepley 
PetscWeakFormViewTable_Ascii(PetscWeakForm wf,PetscViewer viewer,PetscBool splitField,const char tableName[],PetscHMapForm map)954d71ae5a4SJacob Faibussowitsch static PetscErrorCode PetscWeakFormViewTable_Ascii(PetscWeakForm wf, PetscViewer viewer, PetscBool splitField, const char tableName[], PetscHMapForm map)
955d71ae5a4SJacob Faibussowitsch {
95645480ffeSMatthew G. Knepley   PetscInt Nf = wf->Nf, Nk, k;
9576528b96dSMatthew G. Knepley 
9586528b96dSMatthew G. Knepley   PetscFunctionBegin;
9599566063dSJacob Faibussowitsch   PetscCall(PetscHMapFormGetSize(map, &Nk));
9606528b96dSMatthew G. Knepley   if (Nk) {
96106ad1575SMatthew G. Knepley     PetscFormKey *keys;
962*57d50842SBarry Smith     PetscVoidFn **funcs = NULL;
9635fedec97SMatthew G. Knepley     const char  **names;
9645fedec97SMatthew G. Knepley     PetscInt     *values, *idx1, *idx2, *idx;
9655fedec97SMatthew G. Knepley     PetscBool     showPart = PETSC_FALSE, showPointer = PETSC_FALSE;
9665fedec97SMatthew G. Knepley     PetscInt      off = 0;
9676528b96dSMatthew G. Knepley 
9689566063dSJacob Faibussowitsch     PetscCall(PetscMalloc6(Nk, &keys, Nk, &names, Nk, &values, Nk, &idx1, Nk, &idx2, Nk, &idx));
9699566063dSJacob Faibussowitsch     PetscCall(PetscHMapFormGetKeys(map, &off, keys));
9705fedec97SMatthew G. Knepley     /* Sort keys by label name and value */
9715fedec97SMatthew G. Knepley     {
9725fedec97SMatthew G. Knepley       /* First sort values */
9739371c9d4SSatish Balay       for (k = 0; k < Nk; ++k) {
9749371c9d4SSatish Balay         values[k] = keys[k].value;
9759371c9d4SSatish Balay         idx1[k]   = k;
9769371c9d4SSatish Balay       }
9779566063dSJacob Faibussowitsch       PetscCall(PetscSortIntWithPermutation(Nk, values, idx1));
9785fedec97SMatthew G. Knepley       /* If the string sort is stable, it will be sorted correctly overall */
9795fedec97SMatthew G. Knepley       for (k = 0; k < Nk; ++k) {
9809566063dSJacob Faibussowitsch         if (keys[idx1[k]].label) PetscCall(PetscObjectGetName((PetscObject)keys[idx1[k]].label, &names[k]));
981ad540459SPierre Jolivet         else names[k] = "";
9825fedec97SMatthew G. Knepley         idx2[k] = k;
9835fedec97SMatthew G. Knepley       }
9849566063dSJacob Faibussowitsch       PetscCall(PetscSortStrWithPermutation(Nk, names, idx2));
9855fedec97SMatthew G. Knepley       for (k = 0; k < Nk; ++k) {
9869566063dSJacob Faibussowitsch         if (keys[k].label) PetscCall(PetscObjectGetName((PetscObject)keys[k].label, &names[k]));
987ad540459SPierre Jolivet         else names[k] = "";
9885fedec97SMatthew G. Knepley         idx[k] = idx1[idx2[k]];
9895fedec97SMatthew G. Knepley       }
9905fedec97SMatthew G. Knepley     }
9919566063dSJacob Faibussowitsch     PetscCall(PetscViewerASCIIPrintf(viewer, "%s\n", tableName));
9929566063dSJacob Faibussowitsch     PetscCall(PetscViewerASCIIPushTab(viewer));
9936528b96dSMatthew G. Knepley     for (k = 0; k < Nk; ++k) {
9940944a4d6SMatthew G. Knepley       if (keys[k].part != 0) showPart = PETSC_TRUE;
9950944a4d6SMatthew G. Knepley     }
9960944a4d6SMatthew G. Knepley     for (k = 0; k < Nk; ++k) {
9975fedec97SMatthew G. Knepley       const PetscInt i = idx[k];
9985fedec97SMatthew G. Knepley       PetscInt       n, f;
9995fedec97SMatthew G. Knepley 
10005fedec97SMatthew G. Knepley       if (keys[i].label) {
1001c75bfeddSPierre Jolivet         if (showPointer) PetscCall(PetscViewerASCIIPrintf(viewer, "(%s:%p, %" PetscInt_FMT ") ", names[i], (void *)keys[i].label, keys[i].value));
100263a3b9bcSJacob Faibussowitsch         else PetscCall(PetscViewerASCIIPrintf(viewer, "(%s, %" PetscInt_FMT ") ", names[i], keys[i].value));
100363a3b9bcSJacob Faibussowitsch       }
10049566063dSJacob Faibussowitsch       PetscCall(PetscViewerASCIIUseTabs(viewer, PETSC_FALSE));
100563a3b9bcSJacob Faibussowitsch       if (splitField) PetscCall(PetscViewerASCIIPrintf(viewer, "(%" PetscInt_FMT ", %" PetscInt_FMT ") ", keys[i].field / Nf, keys[i].field % Nf));
100663a3b9bcSJacob Faibussowitsch       else PetscCall(PetscViewerASCIIPrintf(viewer, "(%" PetscInt_FMT ") ", keys[i].field));
100763a3b9bcSJacob Faibussowitsch       if (showPart) PetscCall(PetscViewerASCIIPrintf(viewer, "(%" PetscInt_FMT ") ", keys[i].part));
10089566063dSJacob Faibussowitsch       PetscCall(PetscWeakFormGetFunction_Private(wf, map, keys[i].label, keys[i].value, keys[i].field, keys[i].part, &n, &funcs));
10095fedec97SMatthew G. Knepley       for (f = 0; f < n; ++f) {
1010258ec3d2SMatthew G. Knepley         char  *fname;
10115fedec97SMatthew G. Knepley         size_t len, l;
1012258ec3d2SMatthew G. Knepley 
10139566063dSJacob Faibussowitsch         if (f > 0) PetscCall(PetscViewerASCIIPrintf(viewer, ", "));
10149566063dSJacob Faibussowitsch         PetscCall(PetscDLAddr(funcs[f], &fname));
10155fedec97SMatthew G. Knepley         if (fname) {
10165fedec97SMatthew G. Knepley           /* Eliminate argument types */
10179566063dSJacob Faibussowitsch           PetscCall(PetscStrlen(fname, &len));
10189371c9d4SSatish Balay           for (l = 0; l < len; ++l)
10199371c9d4SSatish Balay             if (fname[l] == '(') {
10209371c9d4SSatish Balay               fname[l] = '\0';
10219371c9d4SSatish Balay               break;
10229371c9d4SSatish Balay             }
10239566063dSJacob Faibussowitsch           PetscCall(PetscViewerASCIIPrintf(viewer, "%s", fname));
10245fedec97SMatthew G. Knepley         } else if (showPointer) {
102515943bb8SPierre Jolivet #if defined(__clang__)
1026a8f51744SPierre Jolivet           PETSC_PRAGMA_DIAGNOSTIC_IGNORED_BEGIN("-Wformat-pedantic")
102715943bb8SPierre Jolivet #elif defined(__GNUC__) || defined(__GNUG__)
1028a8f51744SPierre Jolivet           PETSC_PRAGMA_DIAGNOSTIC_IGNORED_BEGIN("-Wformat")
102915943bb8SPierre Jolivet #endif
10309566063dSJacob Faibussowitsch           PetscCall(PetscViewerASCIIPrintf(viewer, "%p", funcs[f]));
1031a8f51744SPierre Jolivet           PETSC_PRAGMA_DIAGNOSTIC_IGNORED_END()
10325fedec97SMatthew G. Knepley         }
10339566063dSJacob Faibussowitsch         PetscCall(PetscFree(fname));
10346528b96dSMatthew G. Knepley       }
10359566063dSJacob Faibussowitsch       PetscCall(PetscViewerASCIIPrintf(viewer, "\n"));
10369566063dSJacob Faibussowitsch       PetscCall(PetscViewerASCIIUseTabs(viewer, PETSC_TRUE));
10376528b96dSMatthew G. Knepley     }
10389566063dSJacob Faibussowitsch     PetscCall(PetscViewerASCIIPopTab(viewer));
10399566063dSJacob Faibussowitsch     PetscCall(PetscFree6(keys, names, values, idx1, idx2, idx));
10406528b96dSMatthew G. Knepley   }
10413ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
10426528b96dSMatthew G. Knepley }
10436528b96dSMatthew G. Knepley 
PetscWeakFormView_Ascii(PetscWeakForm wf,PetscViewer viewer)1044d71ae5a4SJacob Faibussowitsch static PetscErrorCode PetscWeakFormView_Ascii(PetscWeakForm wf, PetscViewer viewer)
1045d71ae5a4SJacob Faibussowitsch {
10466528b96dSMatthew G. Knepley   PetscViewerFormat format;
104706ad1575SMatthew G. Knepley   PetscInt          f;
10486528b96dSMatthew G. Knepley 
10496528b96dSMatthew G. Knepley   PetscFunctionBegin;
10509566063dSJacob Faibussowitsch   PetscCall(PetscViewerGetFormat(viewer, &format));
105163a3b9bcSJacob Faibussowitsch   PetscCall(PetscViewerASCIIPrintf(viewer, "Weak Form System with %" PetscInt_FMT " fields\n", wf->Nf));
10529566063dSJacob Faibussowitsch   PetscCall(PetscViewerASCIIPushTab(viewer));
105348a46eb9SPierre Jolivet   for (f = 0; f < PETSC_NUM_WF; ++f) PetscCall(PetscWeakFormViewTable_Ascii(wf, viewer, PETSC_TRUE, PetscWeakFormKinds[f], wf->form[f]));
10549566063dSJacob Faibussowitsch   PetscCall(PetscViewerASCIIPopTab(viewer));
10553ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
10566528b96dSMatthew G. Knepley }
10576528b96dSMatthew G. Knepley 
1058ffeef943SBarry Smith /*@
1059dce8aebaSBarry Smith   PetscWeakFormView - Views a `PetscWeakForm`
10606528b96dSMatthew G. Knepley 
106120f4b53cSBarry Smith   Collective
10626528b96dSMatthew G. Knepley 
1063d8d19677SJose E. Roman   Input Parameters:
1064dce8aebaSBarry Smith + wf - the `PetscWeakForm` object to view
10656528b96dSMatthew G. Knepley - v  - the viewer
10666528b96dSMatthew G. Knepley 
10676528b96dSMatthew G. Knepley   Level: developer
10686528b96dSMatthew G. Knepley 
1069dce8aebaSBarry Smith .seealso: `PetscViewer`, `PetscWeakForm`, `PetscWeakFormDestroy()`, `PetscWeakFormCreate()`
10706528b96dSMatthew G. Knepley @*/
PetscWeakFormView(PetscWeakForm wf,PetscViewer v)1071d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormView(PetscWeakForm wf, PetscViewer v)
1072d71ae5a4SJacob Faibussowitsch {
10739f196a02SMartin Diehl   PetscBool isascii;
10746528b96dSMatthew G. Knepley 
10756528b96dSMatthew G. Knepley   PetscFunctionBegin;
10766528b96dSMatthew G. Knepley   PetscValidHeaderSpecific(wf, PETSCWEAKFORM_CLASSID, 1);
10779566063dSJacob Faibussowitsch   if (!v) PetscCall(PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject)wf), &v));
1078ad540459SPierre Jolivet   else PetscValidHeaderSpecific(v, PETSC_VIEWER_CLASSID, 2);
10799f196a02SMartin Diehl   PetscCall(PetscObjectTypeCompare((PetscObject)v, PETSCVIEWERASCII, &isascii));
10809f196a02SMartin Diehl   if (isascii) PetscCall(PetscWeakFormView_Ascii(wf, v));
1081dbbe0bcdSBarry Smith   PetscTryTypeMethod(wf, view, v);
10823ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
10836528b96dSMatthew G. Knepley }
10846528b96dSMatthew G. Knepley 
10856528b96dSMatthew G. Knepley /*@
1086dce8aebaSBarry Smith   PetscWeakFormCreate - Creates an empty `PetscWeakForm` object.
10876528b96dSMatthew G. Knepley 
10886528b96dSMatthew G. Knepley   Collective
10896528b96dSMatthew G. Knepley 
10906528b96dSMatthew G. Knepley   Input Parameter:
1091dce8aebaSBarry Smith . comm - The communicator for the `PetscWeakForm` object
10926528b96dSMatthew G. Knepley 
10936528b96dSMatthew G. Knepley   Output Parameter:
1094dce8aebaSBarry Smith . wf - The `PetscWeakForm` object
10956528b96dSMatthew G. Knepley 
10966528b96dSMatthew G. Knepley   Level: beginner
10976528b96dSMatthew G. Knepley 
1098dce8aebaSBarry Smith .seealso: `PetscWeakForm`, `PetscDS`, `PetscWeakFormDestroy()`
10996528b96dSMatthew G. Knepley @*/
PetscWeakFormCreate(MPI_Comm comm,PetscWeakForm * wf)1100d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscWeakFormCreate(MPI_Comm comm, PetscWeakForm *wf)
1101d71ae5a4SJacob Faibussowitsch {
11026528b96dSMatthew G. Knepley   PetscWeakForm p;
110306ad1575SMatthew G. Knepley   PetscInt      f;
11046528b96dSMatthew G. Knepley 
11056528b96dSMatthew G. Knepley   PetscFunctionBegin;
11064f572ea9SToby Isaac   PetscAssertPointer(wf, 2);
11079566063dSJacob Faibussowitsch   PetscCall(PetscDSInitializePackage());
11086528b96dSMatthew G. Knepley 
11099566063dSJacob Faibussowitsch   PetscCall(PetscHeaderCreate(p, PETSCWEAKFORM_CLASSID, "PetscWeakForm", "Weak Form System", "PetscWeakForm", comm, PetscWeakFormDestroy, PetscWeakFormView));
11106528b96dSMatthew G. Knepley   p->Nf = 0;
11119566063dSJacob Faibussowitsch   PetscCall(PetscChunkBufferCreate(sizeof(&PetscWeakFormCreate), 2, &p->funcs));
11129566063dSJacob Faibussowitsch   PetscCall(PetscMalloc1(PETSC_NUM_WF, &p->form));
11139566063dSJacob Faibussowitsch   for (f = 0; f < PETSC_NUM_WF; ++f) PetscCall(PetscHMapFormCreate(&p->form[f]));
11146528b96dSMatthew G. Knepley   *wf = p;
11153ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
11166528b96dSMatthew G. Knepley }
1117