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& diskModelSubDict =
const_cast<dictionary&
>(
125 diskModelSubDict.readEntry<scalarList>(
"center", center);
126 scalar innerRadius = diskModelSubDict.getScalar(
"innerRadius");
127 scalar outerRadius = diskModelSubDict.getScalar(
"outerRadius");
128 scalar POD = diskModelSubDict.getScalar(
"POD");
129 scalar scale = diskModelSubDict.getScalar(
"scale");
130 scalar expM = diskModelSubDict.getScalar(
"expM");
131 scalar expN = diskModelSubDict.getScalar(
"expN");
132 scalar targetThrust = diskModelSubDict.getScalar(
"targetThrust");
137 for (label i = 0; i <
nActDVs_; i++)
145 diskModelSubDict.set(
"center", center);
151 diskModelSubDict.set(
"center", center);
157 diskModelSubDict.set(
"center", center);
162 innerRadius += delta;
163 diskModelSubDict.set(
"innerRadius", innerRadius);
168 outerRadius += delta;
169 diskModelSubDict.set(
"outerRadius", outerRadius);
175 diskModelSubDict.set(
"scale", scale);
181 diskModelSubDict.set(
"POD", POD);
187 diskModelSubDict.set(
"expM", expM);
193 diskModelSubDict.set(
"expN", expN);
197 targetThrust += delta;
198 diskModelSubDict.set(
"targetThrust", targetThrust);
202 fvSource.syncDAOptionToActuatorDVs();
214 diskModelSubDict.set(
"center", center);
220 diskModelSubDict.set(
"center", center);
226 diskModelSubDict.set(
"center", center);
231 innerRadius -= delta;
232 diskModelSubDict.set(
"innerRadius", innerRadius);
237 outerRadius -= delta;
238 diskModelSubDict.set(
"outerRadius", outerRadius);
244 diskModelSubDict.set(
"scale", scale);
250 diskModelSubDict.set(
"POD", POD);
256 diskModelSubDict.set(
"expM", expM);
262 diskModelSubDict.set(
"expN", expN);
266 targetThrust -= delta;
267 diskModelSubDict.set(
"targetThrust", targetThrust);
271 fvSource.syncDAOptionToActuatorDVs();
276 VecAXPY(resVec, -1.0, resVecRef);
277 VecScale(resVec, rDeltaValue);
280 PetscInt Istart, Iend;
281 VecGetOwnershipRange(resVec, &Istart, &Iend);
283 const PetscScalar* resVecArray;
284 VecGetArrayRead(resVec, &resVecArray);
285 for (label j = Istart; j < Iend; j++)
287 label relIdx = j - Istart;
288 PetscScalar val = resVecArray[relIdx];
289 MatSetValue(jacMat, j, i, val, INSERT_VALUES);
291 VecRestoreArrayRead(resVec, &resVecArray);
294 label eTime =
mesh_.time().elapsedClockTime();
295 Info <<
modelType_ <<
" ExecutionTime: " << eTime <<
" s" << endl;
300 MatAssemblyBegin(jacMat, MAT_FINAL_ASSEMBLY);
301 MatAssemblyEnd(jacMat, MAT_FINAL_ASSEMBLY);