Go to the documentation of this file.
41 const dictionary& options,
52 label transposed = options.getLabel(
"transposed");
65 MatSetFromOptions(jacMat);
69 MatZeroEntries(jacMat);
70 Info <<
"Partial derivative matrix created. " <<
mesh_.time().elapsedClockTime() <<
" s" << endl;
74 const dictionary& options,
99 label transposed = options.getLabel(
"transposed");
103 VecDuplicate(wVec, &coloredColumn);
104 VecZeroEntries(coloredColumn);
109 MatZeroEntries(jacMat);
112 VecDuplicate(wVec, &wVecNew);
113 VecCopy(wVec, wVecNew);
116 Vec resVecRef, resVec;
117 VecDuplicate(wVec, &resVec);
118 VecDuplicate(wVec, &resVecRef);
119 VecZeroEntries(resVec);
120 VecZeroEntries(resVecRef);
123 Vec normStatePerturbVec;
127 mOptions.set(
"updateState", 1);
128 mOptions.set(
"updateMesh", 0);
129 mOptions.set(
"setResVec", 1);
130 mOptions.set(
"isPC", options.getLabel(
"isPC"));
133 scalar jacLowerBound = options.getScalar(
"lowerBound");
136 scalar rDelta = 1.0 / delta;
137 PetscScalar rDeltaValue = 0.0;
145 partDerivName +=
"T";
147 if (options.getLabel(
"isPC"))
149 partDerivName +=
"PC";
153 for (label color = 0; color < nColors; color++)
155 label eTime =
mesh_.time().elapsedClockTime();
157 if (color % printInterval == 0 or color == nColors - 1)
159 Info << partDerivName <<
": " << color <<
" of " << nColors
160 <<
", ExecutionTime: " << eTime <<
" s" << endl;
175 VecCopy(wVec, wVecNew);
178 VecAXPY(resVec, -1.0, resVecRef);
179 VecScale(resVec, rDeltaValue);
183 this->
setPartDerivMat(resVec, coloredColumn, transposed, jacMat, jacLowerBound);
189 MatAssemblyBegin(jacMat, MAT_FINAL_ASSEMBLY);
190 MatAssemblyEnd(jacMat, MAT_FINAL_ASSEMBLY);
virtual void calcPartDerivMat(const dictionary &options, const Vec xvVec, const Vec wVec, Mat jacMat)
compute the partial derivative matrix
void calcColoredColumns(const label colorI, Vec coloredColumn) const
calculate the colored column vector
const DAIndex & daIndex_
DAIndex object.
DAOption daOption(mesh, pyOptions_)
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
const DAJacCon & daJacCon_
DAJacCon object.
Vec getJacConColor() const
return DAJacCon::jacConColors_
classType getOption(const word key) const
get an option from subDict and key
const DAOption & daOption_
DAOption object.
label getNJacConColors() const
get the number of JacCon colors
const fvMesh & mesh_
fvMesh
classType getSubDictOption(const word subDict, const word subDictKey) const
get an dictionary option from subDict and key
virtual void initializePartDerivMat(const dictionary &options, Mat jacMat)
initialize partial derivative matrix
#define assignValueCheckAD(valA, valB)
virtual void preallocatedRdW(Mat dRMat, const label transposed) const
preallocate dRdW matrix using the preallocVec
void masterFunction(const dictionary &options, const Vec xvVec, const Vec wVec, Vec resVec)
the master function that compute the residual vector given the state and point vectors
defineTypeNameAndDebug(DAFvSource, 0)
addToRunTimeSelectionTable(DAFvSource, DAFvSourceActuatorDisk, dictionary)
const word modelType_
the name of the jacCon matrix
DAModel daModel(mesh, daOption)
void printMatChars(const Mat matIn) const
print petsc matrix statistics such as the max on/off diagonral ratio
const DAResidual & daResidual_
DAResidual object.
void perturbStates(const Vec jacConColors, const Vec normStatePerturbVec, const label colorI, const scalar delta, Vec wVec)
perturb state variables given a color index
DAIndex daIndex(mesh, daOption, daModel)
void setNormStatePerturbVec(Vec *normStatePerturbVec)
setup the state normalization vector
DAPartDerivdRdW(const word modelType, const fvMesh &mesh, const DAOption &daOption, const DAModel &daModel, const DAIndex &daIndex, const DAJacCon &daJacCon, const DAResidual &daResidual)
label nLocalAdjointStates
number of local adjoint states (including all cells and faces)