41 const dictionary& options,
60 MatSetFromOptions(jacMat);
62 MatSeqAIJSetPreallocation(jacMat,
nActDVs_, NULL);
65 MatZeroEntries(jacMat);
66 Info <<
"Partial derivative matrix created. " <<
mesh_.time().elapsedClockTime() <<
" s" << endl;
70 const dictionary& options,
91 word actuatorName = options.getWord(
"actuatorName");
96 MatZeroEntries(jacMat);
99 Vec resVecRef, resVec;
100 VecDuplicate(wVec, &resVec);
101 VecDuplicate(wVec, &resVecRef);
102 VecZeroEntries(resVec);
103 VecZeroEntries(resVecRef);
106 mOptions.set(
"updateState", 1);
107 mOptions.set(
"updateMesh", 0);
108 mOptions.set(
"setResVec", 1);
109 mOptions.set(
"isPC", options.getLabel(
"isPC"));
113 scalar rDelta = 1.0 / delta;
114 PetscScalar rDeltaValue = 0.0;
118 VecDuplicate(xvVec, &xvVecNew);
119 VecZeroEntries(xvVecNew);
121 dictionary& pointModelSubDict =
const_cast<dictionary&
>(
124 scalarList center, amplitude;
125 pointModelSubDict.readEntry<scalarList>(
"center", center);
126 pointModelSubDict.readEntry<scalarList>(
"amplitude", amplitude);
127 scalar periodicity = pointModelSubDict.getScalar(
"periodicity");
128 scalar phase = pointModelSubDict.getScalar(
"phase");
129 scalar scale = pointModelSubDict.getScalar(
"scale");
131 for (label i = 0; i <
nActDVs_; i++)
139 pointModelSubDict.set(
"center", center);
145 pointModelSubDict.set(
"center", center);
151 pointModelSubDict.set(
"center", center);
156 amplitude[0] += delta;
157 pointModelSubDict.set(
"amplitude", amplitude);
162 amplitude[1] += delta;
163 pointModelSubDict.set(
"amplitude", amplitude);
168 amplitude[2] += delta;
169 pointModelSubDict.set(
"amplitude", amplitude);
174 periodicity += delta;
175 pointModelSubDict.set(
"periodicity", periodicity);
181 pointModelSubDict.set(
"phase", phase);
187 pointModelSubDict.set(
"scale", scale);
200 pointModelSubDict.set(
"center", center);
206 pointModelSubDict.set(
"center", center);
212 pointModelSubDict.set(
"center", center);
217 amplitude[0] -= delta;
218 pointModelSubDict.set(
"amplitude", amplitude);
223 amplitude[1] -= delta;
224 pointModelSubDict.set(
"amplitude", amplitude);
229 amplitude[2] -= delta;
230 pointModelSubDict.set(
"amplitude", amplitude);
235 periodicity -= delta;
236 pointModelSubDict.set(
"periodicity", periodicity);
242 pointModelSubDict.set(
"phase", phase);
248 pointModelSubDict.set(
"scale", scale);
254 VecAXPY(resVec, -1.0, resVecRef);
255 VecScale(resVec, rDeltaValue);
258 PetscInt Istart, Iend;
259 VecGetOwnershipRange(resVec, &Istart, &Iend);
261 const PetscScalar* resVecArray;
262 VecGetArrayRead(resVec, &resVecArray);
263 for (label j = Istart; j < Iend; j++)
265 label relIdx = j - Istart;
266 PetscScalar val = resVecArray[relIdx];
267 MatSetValue(jacMat, j, i, val, INSERT_VALUES);
269 VecRestoreArrayRead(resVec, &resVecArray);
272 label eTime =
mesh_.time().elapsedClockTime();
273 Info <<
modelType_ <<
" ExecutionTime: " << eTime <<
" s" << endl;
278 MatAssemblyBegin(jacMat, MAT_FINAL_ASSEMBLY);
279 MatAssemblyEnd(jacMat, MAT_FINAL_ASSEMBLY);