DAPartDeriv.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2 
3  DAFoam : Discrete Adjoint with OpenFOAM
4  Version : v3
5 
6 \*---------------------------------------------------------------------------*/
7 
8 #include "DAPartDeriv.H"
9 
10 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
11 
12 namespace Foam
13 {
14 
15 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
16 
17 defineTypeNameAndDebug(DAPartDeriv, 0);
18 defineRunTimeSelectionTable(DAPartDeriv, dictionary);
19 
20 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
21 
22 DAPartDeriv::DAPartDeriv(
23  const word modelType,
24  const fvMesh& mesh,
25  const DAOption& daOption,
26  const DAModel& daModel,
27  const DAIndex& daIndex,
28  const DAJacCon& daJacCon,
29  const DAResidual& daResidual)
30  : modelType_(modelType),
31  mesh_(mesh),
32  daOption_(daOption),
33  daModel_(daModel),
34  daIndex_(daIndex),
35  daJacCon_(daJacCon),
36  daResidual_(daResidual),
37  allOptions_(daOption.getAllOptions())
38 {
39  // initialize stateInfo_
40  word solverName = daOption.getOption<word>("solverName");
41  autoPtr<DAStateInfo> daStateInfo(DAStateInfo::New(solverName, mesh, daOption, daModel));
42  stateInfo_ = daStateInfo->getStateInfo();
43 }
44 
45 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
46 
47 autoPtr<DAPartDeriv> DAPartDeriv::New(
48  const word modelType,
49  const fvMesh& mesh,
50  const DAOption& daOption,
51  const DAModel& daModel,
52  const DAIndex& daIndex,
53  const DAJacCon& daJacCon,
54  const DAResidual& daResidual)
55 {
56  if (daOption.getAllOptions().lookupOrDefault<label>("debug", 0))
57  {
58  Info << "Selecting " << modelType << " for DAPartDeriv" << endl;
59  }
60 
61  dictionaryConstructorTable::iterator cstrIter =
62  dictionaryConstructorTablePtr_->find(modelType);
63 
64  // if the solver name is not found in any child class, print an error
65  if (cstrIter == dictionaryConstructorTablePtr_->end())
66  {
67  FatalErrorIn(
68  "DAPartDeriv::New"
69  "("
70  " const word,"
71  " const fvMesh&,"
72  " const DAOption&,"
73  " const DAModel&,"
74  " const DAIndex&,"
75  " const DAJacCon&,"
76  " const DAResidual&"
77  ")")
78  << "Unknown DAPartDeriv type "
79  << modelType << nl << nl
80  << "Valid DAPartDeriv types:" << endl
81  << dictionaryConstructorTablePtr_->sortedToc()
82  << exit(FatalError);
83  }
84 
85  // child class found
86  return autoPtr<DAPartDeriv>(
87  cstrIter()(modelType,
88  mesh,
89  daOption,
90  daModel,
91  daIndex,
92  daJacCon,
93  daResidual));
94 }
95 
96 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
97 
99  const Vec jacConColors,
100  const Vec normStatePerturbVec,
101  const label colorI,
102  const scalar delta,
103  Vec wVec)
104 {
105  /*
106  Descripton:
107  Perturb state variable vec such that it can be used to compute
108  perturbed residual vector later
109 
110  Input:
111  jacConColors: the coloring vector for this Jacobian, obtained from Foam::DAJacCon
112 
113  normStatePerturbVec: state normalization vector, 1.0 means no normalization, the
114  actually perturbation added on the wVec is normStatePerturbVec * delta
115 
116  colorI: we perturb the rows that associated with the coloring index colorI
117 
118  delta: the delta value for perturbation the actually perturbation added on
119  the wVec is normStatePerturbVec * delta
120 
121  Input/Output:
122  wVec: the perturbed state variable vector
123 
124  Example:
125  Assuming we have five element in wVec {0.1, 0.5, 1.0, 1.5, 2.0}
126  If jacConColors reads {0, 0, 1, 0, 1},
127  normStatePerturbVec reads {1.0, 1.0, 0.5, 1.0, 0.1}
128  colorI = 1, delta = 0.01
129 
130  Then after calling this function wVec reads
131  {0.1, 0.5, 1.005, 1.5, 2.001}
132  */
133  PetscInt Istart, Iend;
134  VecGetOwnershipRange(jacConColors, &Istart, &Iend);
135 
136  const PetscScalar* colorArray;
137  VecGetArrayRead(jacConColors, &colorArray);
138 
139  const PetscScalar* normStateArray;
140  VecGetArrayRead(normStatePerturbVec, &normStateArray);
141 
142  PetscScalar* wVecArray;
143  VecGetArray(wVec, &wVecArray);
144 
145  PetscScalar deltaVal = 0.0;
146  assignValueCheckAD(deltaVal, delta);
147 
148  for (label i = Istart; i < Iend; i++)
149  {
150  label relIdx = i - Istart;
151  label colorJ = colorArray[relIdx];
152  if (colorI == colorJ)
153  {
154  wVecArray[relIdx] += deltaVal * normStateArray[relIdx];
155  }
156  }
157 
158  VecRestoreArrayRead(jacConColors, &colorArray);
159  VecRestoreArray(wVec, &wVecArray);
160  VecRestoreArrayRead(normStatePerturbVec, &normStateArray);
161 
162  return;
163 }
164 
166  const Vec resVec,
167  const Vec coloredColumn,
168  const label transposed,
169  Mat jacMat,
170  const scalar jacLowerBound) const
171 {
172  /*
173  Description:
174  Set the values from resVec to jacMat
175 
176  Input:
177  resVec: residual vector, obtained after calling the DAResidual::masterFunction
178 
179  coloredColumn: a vector to determine the element in resVec is associated with
180  which column in the jacMat. coloredColumn is computed in DAJacCon::calcColoredColumns
181  -1 in coloredColumn means don't set values to jacMat for this column
182 
183  transposed: whether the jacMat is transposed or not, for dRdWT transpoed = 1, for
184  all the other cases, set it to 0
185 
186  jacLowerBound: any |value| that is smaller than lowerBound will be set to zero in PartDerivMat
187 
188  Output:
189  jacMat: the jacobian matrix to set
190 
191  Example:
192  Condering a 5 by 5 jacMat with all zeros, and
193 
194  resVec
195  {
196  0.1,
197  0.2,
198  0.3,
199  0.4,
200  0.5
201  }
202 
203  coloredColumn
204  {
205  -1
206  1
207  3
208  -1
209  0
210  }
211 
212  transposed = 0
213 
214  Then, after calling this function, jacMat reads
215 
216  0.0 0.0 0.0 0.0 0.0
217  0.0 0.2 0.0 0.0 0.0
218  0.0 0.0 0.0 0.3 0.0
219  0.0 0.0 0.0 0.0 0.0
220  0.5 0.0 0.0 0.0 0.0
221  */
222 
223  label rowI, colI;
224  PetscScalar val;
225  PetscInt Istart, Iend;
226  const PetscScalar* resVecArray;
227  const PetscScalar* coloredColumnArray;
228 
229  VecGetArrayRead(resVec, &resVecArray);
230  VecGetArrayRead(coloredColumn, &coloredColumnArray);
231 
232  // get the local ownership range
233  VecGetOwnershipRange(resVec, &Istart, &Iend);
234 
235  // Loop over the owned values of this row and set the corresponding
236  // Jacobian entries
237  for (PetscInt i = Istart; i < Iend; i++)
238  {
239  label relIdx = i - Istart;
240  colI = coloredColumnArray[relIdx];
241  if (colI >= 0)
242  {
243  rowI = i;
244  val = resVecArray[relIdx];
245  // if val < bound, don't set the matrix. The exception is that
246  // we always set values for diagonal elements (colI==rowI)
247  // Another exception is that jacLowerBound is less than 1e-16
248  if(jacLowerBound < 1.0e-16 || fabs(val) > jacLowerBound || colI == rowI)
249  {
250  if (transposed)
251  {
252  MatSetValue(jacMat, colI, rowI, val, INSERT_VALUES);
253  }
254  else
255  {
256  MatSetValue(jacMat, rowI, colI, val, INSERT_VALUES);
257  }
258  }
259  }
260  }
261 
262  VecRestoreArrayRead(resVec, &resVecArray);
263  VecRestoreArrayRead(coloredColumn, &coloredColumnArray);
264 }
265 
267  const dictionary options,
268  const scalar delta)
269 {
270  /*
271  Descripton:
272  Perturb values in boundary conditions of the OpenFOAM fields
273 
274  Input:
275  options.varName: the name of the variable to perturb
276 
277  options.patchName: the name of the boundary patches to perturb, do not support
278  multiple patches yet
279 
280  optoins.comp: the component to perturb
281 
282  delta: the delta value to perturb
283  */
284 
285  word varName;
286  wordList patches;
287  label comp;
288  options.readEntry<word>("variable", varName);
289  options.readEntry<wordList>("patches", patches);
290  options.readEntry<label>("comp", comp);
291 
292  // loop over all patches
293  forAll(patches, idxI)
294  {
295  word patchName = patches[idxI];
296 
297  label patchI = mesh_.boundaryMesh().findPatchID(patchName);
298 
299  if (mesh_.thisDb().foundObject<volVectorField>(varName))
300  {
301  volVectorField& state(const_cast<volVectorField&>(
302  mesh_.thisDb().lookupObject<volVectorField>(varName)));
303 
304  // for decomposed domain, don't set BC if the patch is empty
305  if (mesh_.boundaryMesh()[patchI].size() > 0)
306  {
307  if (state.boundaryFieldRef()[patchI].type() == "fixedValue")
308  {
309  forAll(state.boundaryField()[patchI], faceI)
310  {
311  state.boundaryFieldRef()[patchI][faceI][comp] += delta;
312  }
313  }
314  else if (state.boundaryFieldRef()[patchI].type() == "inletOutlet"
315  || state.boundaryFieldRef()[patchI].type() == "outletInlet")
316  {
317  // perturb inletValue
318  mixedFvPatchField<vector>& inletOutletPatch =
319  refCast<mixedFvPatchField<vector>>(state.boundaryFieldRef()[patchI]);
320  vector perturbedValue = inletOutletPatch.refValue()[0];
321  perturbedValue[comp] += delta;
322  inletOutletPatch.refValue() = perturbedValue;
323  }
324  else
325  {
326  FatalErrorIn("") << "boundaryType: " << state.boundaryFieldRef()[patchI].type()
327  << " not supported!"
328  << "Avaiable options are: fixedValue, inletOutlet, outletInlet"
329  << abort(FatalError);
330  }
331  }
332  }
333  else if (mesh_.thisDb().foundObject<volScalarField>(varName))
334  {
335  volScalarField& state(const_cast<volScalarField&>(
336  mesh_.thisDb().lookupObject<volScalarField>(varName)));
337 
338  // for decomposed domain, don't set BC if the patch is empty
339  if (mesh_.boundaryMesh()[patchI].size() > 0)
340  {
341  if (state.boundaryFieldRef()[patchI].type() == "fixedValue")
342  {
343  forAll(state.boundaryField()[patchI], faceI)
344  {
345  state.boundaryFieldRef()[patchI][faceI] += delta;
346  }
347  }
348  else if (state.boundaryFieldRef()[patchI].type() == "inletOutlet"
349  || state.boundaryFieldRef()[patchI].type() == "outletInlet")
350  {
351  // perturb inletValue
352  mixedFvPatchField<scalar>& inletOutletPatch =
353  refCast<mixedFvPatchField<scalar>>(state.boundaryFieldRef()[patchI]);
354  scalar perturbedValue = inletOutletPatch.refValue()[0];
355  perturbedValue += delta;
356  inletOutletPatch.refValue() = perturbedValue;
357  }
358  else
359  {
360  FatalErrorIn("") << "boundaryType: " << state.boundaryFieldRef()[patchI].type()
361  << " not supported!"
362  << "Avaiable options are: fixedValue, inletOutlet, outletInlet"
363  << abort(FatalError);
364  }
365  }
366  }
367  else
368  {
369  FatalErrorIn("") << varName << " is neither volVectorField nor volScalarField!"
370  << abort(FatalError);
371  }
372  }
373 }
374 
376  const dictionary options,
377  const scalar delta)
378 {
379  /*
380  Descripton:
381  Perturb angle of attack in boundary conditions of the OpenFOAM fields
382  Note, OpenFOAM does not have angle of attack BC so we need to specify the
383  x and y components of velocity fields instead.
384  To determine the delta U_x and delta U_y to perturb, we solve
385 
386  (U_x_new)^2 + (U_y_new)^2 = U_mag^2
387  tan(AOA+dAOA) = U_y_new/U_x_new
388 
389  where U_x_new is the perturbed velocity (x component), AOA is the baseline angle
390  of attack and dAOA=delta from input, U_mag is the magnitude of velocity. So the
391  solution of the above equations are:
392 
393  U_x_new = U_mag / sqrt( 1+tan(AOA+dAOA)^2 )
394  U_y_new = U_x_new*tan(AOA+dAOA)
395 
396  Input:
397  options.varName: the name of the variable to perturb
398 
399  options.patchName: the name of the boundary patches to perturb, do not support
400  multiple patches yet
401 
402  options.flowAxis: the streamwise axis, aoa will be atan(U_normal/U_flow)
403 
404  options.normalAxis: the flow normal axis, aoa will be atan(U_normal/U_flow)
405 
406  delta: the delta value to perturb
407  */
408 
409  word varName = "U";
410  wordList patches;
411  options.readEntry<wordList>("patches", patches);
412 
413  HashTable<label> axisIndices;
414  axisIndices.set("x", 0);
415  axisIndices.set("y", 1);
416  axisIndices.set("z", 2);
417  word flowAxis = options.getWord("flowAxis");
418  word normalAxis = options.getWord("normalAxis");
419  label flowAxisIndex = axisIndices[flowAxis];
420  label normalAxisIndex = axisIndices[normalAxis];
421 
422  // loop over all patches
423  forAll(patches, idxI)
424  {
425  word patchName = patches[idxI];
426 
427  label patchI = mesh_.boundaryMesh().findPatchID(patchName);
428 
429  if (mesh_.thisDb().foundObject<volVectorField>(varName))
430  {
431  volVectorField& state(const_cast<volVectorField&>(
432  mesh_.thisDb().lookupObject<volVectorField>(varName)));
433 
434  // for decomposed domain, don't set BC if the patch is empty
435  if (mesh_.boundaryMesh()[patchI].size() > 0)
436  {
437  if (state.boundaryFieldRef()[patchI].type() == "fixedValue")
438  {
439  scalar UmagIn = mag(state.boundaryField()[patchI][0]);
440  scalar Uratio =
441  state.boundaryField()[patchI][0][normalAxisIndex] / state.boundaryField()[patchI][0][flowAxisIndex];
442  //scalar aoa = Foam::radToDeg(atan(Uratio)); // we want the partials in degree
443  scalar aoa = atan(Uratio) * 180.0 / constant::mathematical::pi;
444  scalar aoaNew = aoa + delta;
445  //scalar aoaNewArc = Foam::degToRad(aoaNew);
446  scalar aoaNewArc = aoaNew * constant::mathematical::pi / 180.0;
447 
448  scalar UxNew = UmagIn / sqrt(1 + tan(aoaNewArc) * tan(aoaNewArc));
449  scalar UyNew = UxNew * tan(aoaNewArc);
450 
451  forAll(state.boundaryField()[patchI], faceI)
452  {
453  state.boundaryFieldRef()[patchI][faceI][flowAxisIndex] = UxNew;
454  state.boundaryFieldRef()[patchI][faceI][normalAxisIndex] = UyNew;
455  }
456  }
457  else if (state.boundaryFieldRef()[patchI].type() == "inletOutlet")
458  {
459  // perturb inletValue
460  mixedFvPatchField<vector>& inletOutletPatch =
461  refCast<mixedFvPatchField<vector>>(state.boundaryFieldRef()[patchI]);
462  scalar UmagIn = mag(inletOutletPatch.refValue()[0]);
463 
464  scalar Uratio =
465  inletOutletPatch.refValue()[0][normalAxisIndex] / inletOutletPatch.refValue()[0][flowAxisIndex];
466  //scalar aoa = Foam::radToDeg(atan(Uratio)); // we want the partials in degree
467  scalar aoa = atan(Uratio) * 180.0 / constant::mathematical::pi;
468  scalar aoaNew = aoa + delta;
469  //scalar aoaNewArc = Foam::degToRad(aoaNew);
470  scalar aoaNewArc = aoaNew * constant::mathematical::pi / 180.0;
471 
472  scalar UxNew = UmagIn / sqrt(1 + tan(aoaNewArc) * tan(aoaNewArc));
473  scalar UyNew = UxNew * tan(aoaNewArc);
474 
475  vector UNew = vector::zero;
476  UNew[flowAxisIndex] = UxNew;
477  UNew[normalAxisIndex] = UyNew;
478 
479  inletOutletPatch.refValue() = UNew;
480  }
481  else
482  {
483  FatalErrorIn("") << "boundaryType: " << state.boundaryFieldRef()[patchI].type()
484  << " not supported!"
485  << "Avaiable options are: fixedValue, inletOutlet"
486  << abort(FatalError);
487  }
488  }
489  }
490  else
491  {
492  FatalErrorIn("") << "U is not found in volVectorField!"
493  << abort(FatalError);
494  }
495  }
496 }
497 
498 void DAPartDeriv::setdXvdFFDMat(const Mat dXvdFFDMat)
499 {
500  /*
501  Description:
502  Assign value to dXvdFFDMat_ basically we do a MatConvert
503  */
504 
505  MatConvert(dXvdFFDMat, MATSAME, MAT_INITIAL_MATRIX, &dXvdFFDMat_);
506  //MatDuplicate(dXvdFFDMat, MAT_COPY_VALUES, &dXvdFFDMat_);
507  MatAssemblyBegin(dXvdFFDMat_, MAT_FINAL_ASSEMBLY);
508  MatAssemblyEnd(dXvdFFDMat_, MAT_FINAL_ASSEMBLY);
509 }
510 
511 void DAPartDeriv::setNormStatePerturbVec(Vec* normStatePerturbVec)
512 {
513  /*
514  Description:
515  Set the values for the normStatePerturbVec
516 
517  Input/Output:
518  normStatePerturbVec: the vector to store the state normalization
519  values, this will be used in DAPartDeriv::perturbStates
520 
521  The normalization referene values are set in "normalizeStates" in DAOption
522  */
523  label localSize = daIndex_.nLocalAdjointStates;
524  VecCreate(PETSC_COMM_WORLD, normStatePerturbVec);
525  VecSetSizes(*normStatePerturbVec, localSize, PETSC_DETERMINE);
526  VecSetFromOptions(*normStatePerturbVec);
527  VecSet(*normStatePerturbVec, 1.0);
528 
529  dictionary normStateDict = allOptions_.subDict("normalizeStates");
530 
531  wordList normStateNames = normStateDict.toc();
532 
533  forAll(stateInfo_["volVectorStates"], idxI)
534  {
535  word stateName = stateInfo_["volVectorStates"][idxI];
536  if (DAUtility::isInList<word>(stateName, normStateNames))
537  {
538  scalar scale = normStateDict.getScalar(stateName);
539  PetscScalar scaleValue = 0.0;
540  assignValueCheckAD(scaleValue, scale);
541  forAll(mesh_.cells(), idxI)
542  {
543  for (label comp = 0; comp < 3; comp++)
544  {
545  label glbIdx = daIndex_.getGlobalAdjointStateIndex(stateName, idxI, comp);
546  VecSetValue(*normStatePerturbVec, glbIdx, scaleValue, INSERT_VALUES);
547  }
548  }
549  }
550  }
551 
552  forAll(stateInfo_["volScalarStates"], idxI)
553  {
554  const word stateName = stateInfo_["volScalarStates"][idxI];
555  if (DAUtility::isInList<word>(stateName, normStateNames))
556  {
557  scalar scale = normStateDict.getScalar(stateName);
558  PetscScalar scaleValue = 0.0;
559  assignValueCheckAD(scaleValue, scale);
560  forAll(mesh_.cells(), idxI)
561  {
562  label glbIdx = daIndex_.getGlobalAdjointStateIndex(stateName, idxI);
563  VecSetValue(*normStatePerturbVec, glbIdx, scaleValue, INSERT_VALUES);
564  }
565  }
566  }
567 
568  forAll(stateInfo_["modelStates"], idxI)
569  {
570  const word stateName = stateInfo_["modelStates"][idxI];
571  if (DAUtility::isInList<word>(stateName, normStateNames))
572  {
573  scalar scale = normStateDict.getScalar(stateName);
574  PetscScalar scaleValue = 0.0;
575  assignValueCheckAD(scaleValue, scale);
576  forAll(mesh_.cells(), idxI)
577  {
578  label glbIdx = daIndex_.getGlobalAdjointStateIndex(stateName, idxI);
579  VecSetValue(*normStatePerturbVec, glbIdx, scaleValue, INSERT_VALUES);
580  }
581  }
582  }
583 
584  forAll(stateInfo_["surfaceScalarStates"], idxI)
585  {
586  const word stateName = stateInfo_["surfaceScalarStates"][idxI];
587  if (DAUtility::isInList<word>(stateName, normStateNames))
588  {
589  scalar scale = normStateDict.getScalar(stateName);
590  PetscScalar scaleValue = 0.0;
591 
592  forAll(mesh_.faces(), faceI)
593  {
594  if (faceI < daIndex_.nLocalInternalFaces)
595  {
596  scale = mesh_.magSf()[faceI];
597  assignValueCheckAD(scaleValue, scale);
598  }
599  else
600  {
601  label relIdx = faceI - daIndex_.nLocalInternalFaces;
602  label patchIdx = daIndex_.bFacePatchI[relIdx];
603  label faceIdx = daIndex_.bFaceFaceI[relIdx];
604  scale = mesh_.magSf().boundaryField()[patchIdx][faceIdx];
605  assignValueCheckAD(scaleValue, scale);
606  }
607 
608  label glbIdx = daIndex_.getGlobalAdjointStateIndex(stateName, faceI);
609  VecSetValue(*normStatePerturbVec, glbIdx, scaleValue, INSERT_VALUES);
610  }
611  }
612  }
613 
614  VecAssemblyBegin(*normStatePerturbVec);
615  VecAssemblyEnd(*normStatePerturbVec);
616 }
617 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
618 
619 } // End namespace Foam
620 
621 // ************************************************************************* //
Foam::DAJacCon
Definition: DAJacCon.H:34
forAll
forAll(pseudoP.boundaryField(), patchI)
Definition: solvePseudoPEqn.H:10
Foam::DAStateInfo::New
static autoPtr< DAStateInfo > New(const word modelType, const fvMesh &mesh, const DAOption &daOption, const DAModel &daModel)
Definition: DAStateInfo.C:43
Foam::DAIndex::bFacePatchI
labelList bFacePatchI
Definition: DAIndex.H:110
Foam::DAOption
Definition: DAOption.H:29
Foam::DAIndex::getGlobalAdjointStateIndex
label getGlobalAdjointStateIndex(const word stateName, const label idxI, const label comp=-1) const
get global adjoint index for a given state name, cell/face indxI and its component (optional,...
Definition: DAIndex.C:661
Foam::DAPartDeriv::daIndex_
const DAIndex & daIndex_
DAIndex object.
Definition: DAPartDeriv.H:60
daOption
DAOption daOption(mesh, pyOptions_)
Foam::DAPartDeriv::setPartDerivMat
void setPartDerivMat(const Vec resVec, const Vec coloredColumn, const label transposed, Mat jacMat, const scalar jacLowerBound=1e-30) const
set values for the partial derivative matrix
Definition: DAPartDeriv.C:165
Foam::DAPartDeriv::mesh_
const fvMesh & mesh_
fvMesh
Definition: DAPartDeriv.H:51
mesh
fvMesh & mesh
Definition: createRefsHeatTransfer.H:4
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(DAFvSource, dictionary)
solverName
word solverName
Definition: createAdjointCompressible.H:30
Foam::DAPartDeriv::stateInfo_
HashTable< wordList > stateInfo_
the stateInfo_ list from DAStateInfo object
Definition: DAPartDeriv.H:72
Foam::DAIndex
Definition: DAIndex.H:32
assignValueCheckAD
#define assignValueCheckAD(valA, valB)
Definition: DAMacroFunctions.H:103
Foam::DAPartDeriv::New
static autoPtr< DAPartDeriv > New(const word modelType, const fvMesh &mesh, const DAOption &daOption, const DAModel &daModel, const DAIndex &daIndex, const DAJacCon &daJacCon, const DAResidual &daResidual)
Definition: DAPartDeriv.C:47
Foam::DAModel
Definition: DAModel.H:59
Foam
Definition: multiFreqScalarFvPatchField.C:144
Foam::DAPartDeriv::perturbAOA
void perturbAOA(const dictionary options, const scalar delta)
perturb the angle of attack
Definition: DAPartDeriv.C:375
Foam::DAIndex::nLocalInternalFaces
label nLocalInternalFaces
local internal face size
Definition: DAIndex.H:98
Foam::DAResidual
Definition: DAResidual.H:35
DAPartDeriv.H
Foam::DAPartDeriv::perturbBC
void perturbBC(const dictionary options, const scalar delta)
perturb the values in the boundary condition
Definition: DAPartDeriv.C:266
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(DAFvSource, 0)
daModel
DAModel daModel(mesh, daOption)
Foam::DAPartDeriv::setdXvdFFDMat
void setdXvdFFDMat(const Mat dXvdFFDMat)
setup dXvdFFD matrix
Definition: DAPartDeriv.C:498
Foam::DAPartDeriv::perturbStates
void perturbStates(const Vec jacConColors, const Vec normStatePerturbVec, const label colorI, const scalar delta, Vec wVec)
perturb state variables given a color index
Definition: DAPartDeriv.C:98
Foam::DAPartDeriv::dXvdFFDMat_
Mat dXvdFFDMat_
volume mesh coordinates wrt the ffd point coordinate partials
Definition: DAPartDeriv.H:101
daIndex
DAIndex daIndex(mesh, daOption, daModel)
Foam::DAPartDeriv::setNormStatePerturbVec
void setNormStatePerturbVec(Vec *normStatePerturbVec)
setup the state normalization vector
Definition: DAPartDeriv.C:511
Foam::DAPartDeriv::allOptions_
const dictionary & allOptions_
all the DAFoam option
Definition: DAPartDeriv.H:69
Foam::DAIndex::bFaceFaceI
labelList bFaceFaceI
Definition: DAIndex.H:116
Foam::DAIndex::nLocalAdjointStates
label nLocalAdjointStates
number of local adjoint states (including all cells and faces)
Definition: DAIndex.H:145