85 labelList objFuncFaceSources;
86 labelList objFuncCellSources;
87 options.readEntry<labelList>(
"objFuncFaceSources", objFuncFaceSources);
88 options.readEntry<labelList>(
"objFuncCellSources", objFuncCellSources);
98 MatCreate(PETSC_COMM_WORLD, &
jacCon_);
101 nLocalObjFuncGeoElements,
106 MatMPIAIJSetPreallocation(
jacCon_, 200, NULL, 200, NULL);
107 MatSeqAIJSetPreallocation(
jacCon_, 200, NULL);
112 Info <<
"dFdWCon Created!" << endl;
132 Info <<
"Setting up dFdWCon.." << endl;
136 Mat connectedStatesP;
138 List<List<word>> objFuncConInfo;
139 labelList objFuncFaceSources;
140 labelList objFuncCellSources;
141 options.readEntry<List<List<word>>>(
"objFuncConInfo", objFuncConInfo);
142 options.readEntry<labelList>(
"objFuncFaceSources", objFuncFaceSources);
143 options.readEntry<labelList>(
"objFuncCellSources", objFuncCellSources);
146 label maxConLevel = objFuncConInfo.size() - 1;
148 forAll(objFuncFaceSources, idxI)
151 const label& objFuncFaceI = objFuncFaceSources[idxI];
157 const fvPatch& patch =
mesh_.boundary()[patchI];
159 const UList<label>& pFaceCells = patch.faceCells();
162 label idxN = pFaceCells[faceI];
167 forAll(objFuncConInfo, idxJ)
170 wordList connectedStatesLocal(0);
171 forAll(objFuncConInfo[idxJ], idxK)
173 word conName = objFuncConInfo[idxJ][idxK];
178 connectedStatesLocal.append(conName);
183 List<List<word>> connectedStatesInterProc;
188 connectedStatesInterProc.setSize(0);
190 else if (idxJ != maxConLevel)
192 connectedStatesInterProc.setSize(maxConLevel - idxJ + 1);
193 for (label
k = 0;
k < maxConLevel - idxJ + 1;
k++)
195 label conSize = objFuncConInfo[
k + idxJ].size();
196 for (label l = 0; l < conSize; l++)
198 word conName = objFuncConInfo[
k + idxJ][l];
203 connectedStatesInterProc[
k].append(conName);
210 connectedStatesInterProc.setSize(1);
211 label conSize = objFuncConInfo[maxConLevel].size();
212 for (label l = 0; l < conSize; l++)
214 word conName = objFuncConInfo[maxConLevel][l];
219 connectedStatesInterProc[0].append(conName);
228 word conName =
stateInfo_[
"surfaceScalarStates"][idxK];
229 if (DAUtility::isInList<word>(conName, objFuncConInfo[idxJ]))
239 connectedStatesLocal,
240 connectedStatesInterProc,
249 forAll(objFuncCellSources, idxI)
251 label cellI = objFuncCellSources[idxI];
256 forAll(objFuncConInfo, idxJ)
259 wordList connectedStatesLocal = objFuncConInfo[idxJ];
262 List<List<word>> connectedStatesInterProc;
267 connectedStatesInterProc.setSize(0);
269 else if (idxJ != maxConLevel)
271 connectedStatesInterProc.setSize(maxConLevel - idxJ + 1);
272 for (label
k = 0;
k < maxConLevel - idxJ + 1;
k++)
274 connectedStatesInterProc[
k] = objFuncConInfo[
k + idxJ];
279 connectedStatesInterProc.setSize(1);
280 connectedStatesInterProc[0] = objFuncConInfo[maxConLevel];
287 word conName =
stateInfo_[
"surfaceScalarStates"][idxK];
288 if (DAUtility::isInList<word>(conName, objFuncConInfo[idxJ]))
298 connectedStatesLocal,
299 connectedStatesInterProc,
308 MatAssemblyBegin(
jacCon_, MAT_FINAL_ASSEMBLY);
309 MatAssemblyEnd(
jacCon_, MAT_FINAL_ASSEMBLY);
312 wordList writeJacobians;
314 if (writeJacobians.found(
"dFdWCon"))
322 const label idxI)
const
355 label localIdx = -9999;
356 if (idxType ==
"face")
360 else if (idxType ==
"cell")
366 FatalErrorIn(
"") <<
"idxType: " << idxType <<
"not supported!"
367 << abort(FatalError);
374 const label idxI)
const
412 scalarList objFuncFaceValues,
413 scalarList objFuncCellValues,
414 Vec objFuncVec)
const
429 PetscScalar* objFuncVecArray;
430 VecGetArray(objFuncVec, &objFuncVecArray);
432 forAll(objFuncFaceValues, idxI)
438 forAll(objFuncCellValues, idxI)
444 VecRestoreArray(objFuncVec, &objFuncVecArray);