41 const dictionary& options,
61 MatSetFromOptions(jacMat);
62 MatMPIAIJSetPreallocation(jacMat, 1, NULL, 1, NULL);
63 MatSeqAIJSetPreallocation(jacMat, 1, NULL);
66 MatZeroEntries(jacMat);
67 Info <<
"Partial derivative matrix created. " <<
mesh_.time().elapsedClockTime() <<
" s" << endl;
71 const dictionary& options,
96 word objFuncName, objFuncPart;
97 dictionary objFuncSubDictPart = options.subDict(
"objFuncSubDictPart");
98 options.readEntry<word>(
"objFuncName", objFuncName);
99 options.readEntry<word>(
"objFuncPart", objFuncPart);
101 autoPtr<DAObjFunc> daObjFunc(
114 MatZeroEntries(jacMat);
116 word actuatorName = options.getWord(
"actuatorName");
119 mOptions.set(
"updateState", 1);
120 mOptions.set(
"updateMesh", 0);
121 scalar fRef = daObjFunc->masterFunction(mOptions, xvVec, wVec);
124 scalar rDelta = 1.0 / delta;
126 dictionary& diskModelSubDict =
const_cast<dictionary&
>(
130 diskModelSubDict.readEntry<scalarList>(
"center", center);
131 scalar innerRadius = diskModelSubDict.getScalar(
"innerRadius");
132 scalar outerRadius = diskModelSubDict.getScalar(
"outerRadius");
133 scalar POD = diskModelSubDict.getScalar(
"POD");
134 scalar scale = diskModelSubDict.getScalar(
"scale");
135 scalar expM = diskModelSubDict.getScalar(
"expM");
136 scalar expN = diskModelSubDict.getScalar(
"expN");
137 scalar targetThrust = diskModelSubDict.getScalar(
"targetThrust");
142 for (label i = 0; i <
nActDVs_; i++)
149 diskModelSubDict.set(
"center", center);
155 diskModelSubDict.set(
"center", center);
161 diskModelSubDict.set(
"center", center);
166 innerRadius += delta;
167 diskModelSubDict.set(
"innerRadius", innerRadius);
172 outerRadius += delta;
173 diskModelSubDict.set(
"outerRadius", outerRadius);
179 diskModelSubDict.set(
"scale", scale);
185 diskModelSubDict.set(
"POD", POD);
191 diskModelSubDict.set(
"expM", expM);
197 diskModelSubDict.set(
"expN", expN);
201 targetThrust += delta;
202 diskModelSubDict.set(
"targetThrust", targetThrust);
206 fvSource.syncDAOptionToActuatorDVs();
210 scalar fNew = daObjFunc->masterFunction(mOptions, xvVec, wVec);
217 diskModelSubDict.set(
"center", center);
223 diskModelSubDict.set(
"center", center);
229 diskModelSubDict.set(
"center", center);
234 innerRadius -= delta;
235 diskModelSubDict.set(
"innerRadius", innerRadius);
240 outerRadius -= delta;
241 diskModelSubDict.set(
"outerRadius", outerRadius);
247 diskModelSubDict.set(
"scale", scale);
253 diskModelSubDict.set(
"POD", POD);
259 diskModelSubDict.set(
"expM", expM);
265 diskModelSubDict.set(
"expN", expN);
269 targetThrust -= delta;
270 diskModelSubDict.set(
"targetThrust", targetThrust);
274 fvSource.syncDAOptionToActuatorDVs();
277 scalar partDeriv = (fNew - fRef) * rDelta;
278 PetscScalar partDerivValue = 0.0;
281 MatSetValue(jacMat, i, 0, partDerivValue, INSERT_VALUES);
286 fRef = daObjFunc->masterFunction(mOptions, xvVec, wVec);
290 Info << objFuncName <<
": " << fRef << endl;
293 MatAssemblyBegin(jacMat, MAT_FINAL_ASSEMBLY);
294 MatAssemblyEnd(jacMat, MAT_FINAL_ASSEMBLY);