41 const dictionary& options,
60 MatSetFromOptions(jacMat);
61 MatMPIAIJSetPreallocation(jacMat, 1, NULL, 1, NULL);
62 MatSeqAIJSetPreallocation(jacMat, 1, NULL);
65 MatZeroEntries(jacMat);
66 Info <<
"Partial derivative matrix created. " <<
mesh_.time().elapsedClockTime() <<
" s" << endl;
70 const dictionary& options,
95 word objFuncName, objFuncPart;
96 dictionary objFuncSubDictPart = options.subDict(
"objFuncSubDictPart");
97 options.readEntry<word>(
"objFuncName", objFuncName);
98 options.readEntry<word>(
"objFuncPart", objFuncPart);
100 autoPtr<DAObjFunc> daObjFunc(
113 MatZeroEntries(jacMat);
116 mOptions.set(
"updateState", 1);
117 mOptions.set(
"updateMesh", 0);
118 scalar fRef = daObjFunc->masterFunction(mOptions, xvVec, wVec);
121 scalar rDelta = 1.0 / delta;
127 scalar fNew = daObjFunc->masterFunction(mOptions, xvVec, wVec);
129 scalar partDeriv = (fNew - fRef) * rDelta;
130 PetscScalar partDerivValue = 0.0;
133 MatSetValue(jacMat, 0, 0, partDerivValue, INSERT_VALUES);
138 fRef = daObjFunc->masterFunction(mOptions, xvVec, wVec);
142 Info << objFuncName <<
": " << fRef << endl;
145 MatAssemblyBegin(jacMat, MAT_FINAL_ASSEMBLY);
146 MatAssemblyEnd(jacMat, MAT_FINAL_ASSEMBLY);