41 const dictionary& options,
63 MatSetFromOptions(jacMat);
64 MatMPIAIJSetPreallocation(jacMat, 1, NULL, 1, NULL);
65 MatSeqAIJSetPreallocation(jacMat, 1, NULL);
68 MatZeroEntries(jacMat);
69 Info <<
"Partial derivative matrix created. " <<
mesh_.time().elapsedClockTime() <<
" s" << endl;
73 const dictionary& options,
97 MatZeroEntries(jacMat);
100 Vec resVecRef, resVec;
101 VecDuplicate(wVec, &resVec);
102 VecDuplicate(wVec, &resVecRef);
103 VecZeroEntries(resVec);
104 VecZeroEntries(resVecRef);
107 mOptions.set(
"updateState", 1);
108 mOptions.set(
"updateMesh", 0);
109 mOptions.set(
"setResVec", 1);
110 mOptions.set(
"isPC", options.getLabel(
"isPC"));
114 scalar rDelta = 1.0 / delta;
115 PetscScalar rDeltaValue = 0.0;
125 VecAXPY(resVec, -1.0, resVecRef);
126 VecScale(resVec, rDeltaValue);
129 PetscInt Istart, Iend;
130 VecGetOwnershipRange(resVec, &Istart, &Iend);
132 const PetscScalar* resVecArray;
133 VecGetArrayRead(resVec, &resVecArray);
134 for (label i = Istart; i < Iend; i++)
136 label relIdx = i - Istart;
137 PetscScalar val = resVecArray[relIdx];
138 MatSetValue(jacMat, i, 0, val, INSERT_VALUES);
140 VecRestoreArrayRead(resVec, &resVecArray);
147 MatAssemblyBegin(jacMat, MAT_FINAL_ASSEMBLY);
148 MatAssemblyEnd(jacMat, MAT_FINAL_ASSEMBLY);