Go to the documentation of this file.
44 autoPtr<DASolver> DASolverPtr_;
60 DASolverPtr_->initSolver();
68 return DASolverPtr_->solvePrimal(xvVec, wVec);
78 DASolverPtr_->calcdRdWT(xvVec, wVec, isPC, dRdWT);
85 const word objFuncName,
88 DASolverPtr_->calcdFdW(xvVec, wVec, objFuncName, dFdW);
95 const word objFuncName,
98 DASolverPtr_->calcdFdWAD(xvVec, wVec, objFuncName, dFdW);
105 const word objFuncName,
106 const word designVarName,
109 DASolverPtr_->calcdFdXvAD(xvVec, wVec, objFuncName, designVarName, dFdXv);
119 DASolverPtr_->calcdRdXvTPsiAD(xvVec, wVec,
psi, dRdXvTPsi);
129 DASolverPtr_->calcdForcedXvAD(xvVec, wVec, fBarVec, dForcedW);
141 DASolverPtr_->calcdAcousticsdXvAD(xvVec, wVec, fBarVec, dAcoudW, varName, groupName);
149 const word designVarName,
152 DASolverPtr_->calcdRdActTPsiAD(xvVec, wVec,
psi, designVarName, dRdActTPsi);
162 DASolverPtr_->calcdForcedWAD(xvVec, wVec, fBarVec, dForcedW);
174 DASolverPtr_->calcdAcousticsdWAD(xvVec, wVec, fBarVec, dAcoudW, varName, groupName);
182 const word designVarName,
185 DASolverPtr_->calcdRdAOATPsiAD(xvVec, wVec,
psi, designVarName, dRdAOATPsi);
194 DASolverPtr_->createMLRKSP(jacMat, jacPCMat, ksp);
202 DASolverPtr_->createMLRKSPMatrixFree(jacPCMat, ksp);
210 DASolverPtr_->initializedRdWTMatrixFree(xvVec, wVec);
216 DASolverPtr_->destroydRdWTMatrixFree();
225 DASolverPtr_->solveLinearEqn(ksp, rhsVec, solVec);
233 DASolverPtr_->convertMPIVec2SeqVec(mpiVec, seqVec);
240 const word designVarName,
243 DASolverPtr_->calcdRdBC(xvVec, wVec, designVarName, dRdBC);
250 const word objFuncName,
251 const word designVarName,
254 DASolverPtr_->calcdFdBC(xvVec, wVec, objFuncName, designVarName, dFdBC);
261 const word objFuncName,
262 const word designVarName,
265 DASolverPtr_->calcdFdBCAD(xvVec, wVec, objFuncName, designVarName, dFdBC);
273 const word designVarName,
276 DASolverPtr_->calcdRdBCTPsiAD(xvVec, wVec,
psi, designVarName, dRdBCTPsi);
283 const word designVarName,
286 DASolverPtr_->calcdRdAOA(xvVec, wVec, designVarName, dRdAOA);
293 const word objFuncName,
294 const word designVarName,
297 DASolverPtr_->calcdFdAOA(xvVec, wVec, objFuncName, designVarName, dFdAOA);
304 const word designVarName,
307 DASolverPtr_->calcdRdFFD(xvVec, wVec, designVarName, dRdFFD);
314 const word objFuncName,
315 const word designVarName,
318 DASolverPtr_->calcdFdFFD(xvVec, wVec, objFuncName, designVarName, dFdFFD);
325 const word designVarName,
326 const word designVarType,
329 DASolverPtr_->calcdRdACT(xvVec, wVec, designVarName, designVarType, dRdACT);
336 const word objFuncName,
337 const word designVarName,
340 DASolverPtr_->calcdFdACTAD(xvVec, wVec, objFuncName, designVarName, dFdACT);
347 const word objFuncName,
348 const word designVarName,
349 const word designVarType,
352 DASolverPtr_->calcdFdACT(xvVec, wVec, objFuncName, designVarName, designVarType, dFdACT);
360 const word designVarName,
363 DASolverPtr_->calcdRdFieldTPsiAD(xvVec, wVec,
psi, designVarName, dRdFieldTPsi);
370 const word objFuncName,
371 const word designVarName,
374 DASolverPtr_->calcdFdFieldAD(xvVec, wVec, objFuncName, designVarName, dFdField);
379 const label oldTimeLevel,
383 DASolverPtr_->calcdRdWOldTPsiAD(oldTimeLevel,
psi, dRdWOldTPsi);
393 DASolverPtr_->calcdRdWTPsiAD(xvVec, wVec,
psi, dRdWTPsi);
399 DASolverPtr_->updateOFField(wVec);
405 DASolverPtr_->updateOFMesh(xvVec);
410 const label idxPoint,
411 const label idxCoord)
const
413 return DASolverPtr_->getGlobalXvIndex(idxPoint, idxCoord);
419 DASolverPtr_->ofField2StateVec(stateVec);
425 DASolverPtr_->stateVec2OFField(stateVec);
431 return DASolverPtr_->checkMesh();
437 return DASolverPtr_->getNCouplingFaces();
443 return DASolverPtr_->getNCouplingPoints();
449 return DASolverPtr_->getNLocalPoints();
455 return DASolverPtr_->getNLocalAdjointStates();
461 return DASolverPtr_->getNLocalAdjointBoundaryStates();
467 return DASolverPtr_->getNLocalCells();
473 DASolverPtr_->syncDAOptionToActuatorDVs();
479 double returnVal = 0.0;
485 const double* volCoords,
488 #if !defined(CODI_AD_REVERSE) && !defined(CODI_AD_FORWARD)
489 DASolverPtr_->calcCouplingFaceCoords(volCoords, surfCoords);
492 FatalErrorIn(
"calcCouplingFaceCoords") <<
"should not call this func in AD mode!"
493 << abort(FatalError);
498 const double* volCoords,
502 DASolverPtr_->calcCouplingFaceCoordsAD(volCoords, seeds, product);
508 DASolverPtr_->getForces(fX, fY, fZ);
513 const double* volCoords,
514 const double* states,
517 #if !defined(CODI_AD_REVERSE) && !defined(CODI_AD_FORWARD)
518 DASolverPtr_->getThermal(volCoords, states, thermal);
521 FatalErrorIn(
"getThermal") <<
"should not call this func in AD mode!"
522 << abort(FatalError);
527 const word inputName,
528 const double* volCoords,
529 const double* states,
533 DASolverPtr_->getThermalAD(inputName, volCoords, states, seeds, product);
539 #if !defined(CODI_AD_REVERSE) && !defined(CODI_AD_FORWARD)
540 DASolverPtr_->setThermal(thermal);
543 FatalErrorIn(
"setThermal") <<
"should not call this func in AD mode!"
544 << abort(FatalError);
548 const double* volCoords,
549 const double* states,
550 const double* thermal,
554 DASolverPtr_->calcdRdThermalTPsiAD(volCoords, states, thermal, seeds, product);
558 void getAcousticData(Vec x, Vec y, Vec z, Vec nX, Vec nY, Vec nZ, Vec a, Vec fX, Vec fY, Vec fZ, word groupName)
560 DASolverPtr_->getAcousticData(x, y, z, nX, nY, nZ, a, fX, fY, fZ, groupName);
566 DASolverPtr_->printAllOptions();
572 DASolverPtr_->setdXvdFFDMat(dXvdFFDMat);
578 DASolverPtr_->setFFD2XvSeedVec(vecIn);
584 DASolverPtr_->updateDAOption(pyOptions);
590 double returnVal = 0.0;
598 DASolverPtr_->pointVec2OFMesh(xvVec);
604 DASolverPtr_->ofMesh2PointVec(xvVec);
610 DASolverPtr_->resVec2OFResField(resVec);
616 DASolverPtr_->resVec2OFResField(resVec);
624 DASolverPtr_->writeMatrixBinary(matIn, prefix);
632 DASolverPtr_->writeMatrixASCII(matIn, prefix);
640 DASolverPtr_->readMatrixBinary(matIn, prefix);
648 DASolverPtr_->writeVectorASCII(vecIn, prefix);
656 DASolverPtr_->readVectorBinary(vecIn, prefix);
664 DASolverPtr_->writeVectorBinary(vecIn, prefix);
670 DASolverPtr_->setTimeInstanceField(instanceI);
681 DASolverPtr_->setTimeInstanceVar(
mode, stateMat, stateBCMat, timeVec, timeIdxVec);
686 const label instanceI,
687 const word objFuncName)
689 double returnVal = 0.0;
690 assignValueCheckAD(returnVal, DASolverPtr_->getTimeInstanceObjFunc(instanceI, objFuncName));
696 const word fieldName,
698 const label globalCellI,
699 const label compI = 0)
701 DASolverPtr_->setFieldValue4GlobalCellI(fieldName, val, globalCellI, compI);
706 const word fieldName,
708 const label localCellI,
709 const label compI = 0)
711 DASolverPtr_->setFieldValue4LocalCellI(fieldName, val, localCellI, compI);
716 const word fieldName,
717 const word fieldType)
719 DASolverPtr_->updateBoundaryConditions(fieldName, fieldType);
725 DASolverPtr_->calcPrimalResidualStatistics(
mode, 0);
731 return DASolverPtr_->getForwardADDerivVal(objFuncName);
737 DASolverPtr_->calcResidualVec(resVec);
742 DASolverPtr_->setPrimalBoundaryConditions(printInfo);
755 DASolverPtr_->calcFvSource(propName, aForce, tForce, rDist, targetForce, center,
fvSource);
769 DASolverPtr_->calcdFvSourcedInputsTPsiAD(propName,
mode, aForce, tForce, rDist, targetForce, center,
psi, dFvSource);
778 DASolverPtr_->calcForceProfile(center, aForceL, tForceL, rDistL);
788 DASolverPtr_->calcdForcedStateTPsiAD(
mode, xvVec, stateVec, psiVec, prodVec);
797 return DASolverPtr_->runFPAdj(xvVec, wVec, dFdW,
psi);
807 DASolverPtr_->initTensorFlowFuncs(computeInterface, compute, jacVecProdInterface, jacVecProd);
void stateVec2OFField(const Vec stateVec) const
basically, we call DASolver::stateVec2OFField
void getThermalAD(const word inputName, const double *volCoords, const double *states, const double *seeds, double *product)
compute the temperature on the conjugate heat transfer patches AD
void writeVectorBinary(const Vec vecIn, const word prefix)
write petsc vector in binary format
void calcdForcedWAD(const Vec xvVec, const Vec wVec, const Vec fBarVec, Vec dForcedW)
compute dForcedW
void ofMesh2PointVec(Vec xvVec) const
assign the point vector based on the points in fvMesh of OpenFOAM
void calcPrimalResidualStatistics(const word mode)
Calculate the mean, max, and norm2 for all residuals and print it to screen.
void updateBoundaryConditions(const word fieldName, const word fieldType)
update the boundary condition for a field
void setFFD2XvSeedVec(Vec vecIn)
set the value for DASolver::FFD2XvSeedVec_
void getThermal(const double *volCoords, const double *states, double *thermal)
return the thermal (temperature or heat flux) on the conjugate heat transfer patches
label getGlobalXvIndex(const label idxPoint, const label idxCoord) const
basically, we call DAIndex::getGlobalXvIndex
void resVec2OFResField(const Vec resVec) const
assign the OpenFOAM residual fields based on the resVec
label checkMesh() const
basically, we call DASolver::checkMesh
double getPrevPrimalSolTime()
get the solution time folder for previous primal solution
virtual ~DASolvers()
Destructor.
void syncDAOptionToActuatorDVs()
synchronize the values in DAOption and actuatorDiskDVs_
void setdXvdFFDMat(const Mat dXvdFFDMat)
set values for dXvdFFDMat
void createMLRKSPMatrixFree(const Mat jacPCMat, KSP ksp)
create a multi-level, Richardson KSP object with matrix-free Jacobians
void calcdRdFieldTPsiAD(const Vec xvVec, const Vec wVec, const Vec psi, const word designVarName, Vec dRdFieldTPsi)
compute dRdField
void calcdFdFieldAD(const Vec xvVec, const Vec wVec, const word objFuncName, const word designVarName, Vec dFdField)
compute dFdField
void writeMatrixBinary(const Mat matIn, const word prefix)
write the matrix in binary format
void calcdRdWTPsiAD(const Vec xvVec, const Vec wVec, const Vec psi, Vec dRdWTPsi)
compute [dRdW]^T*Psi
void writeVectorASCII(const Vec vecIn, const word prefix)
write petsc vector in ascii format
void calcdFdWAD(const Vec xvVec, const Vec wVec, const word objFuncName, Vec dFdW)
compute dFdW using reverse-mode AD
void getForces(Vec fX, Vec fY, Vec fZ)
return the force on the FSI patches
void calcdAcousticsdWAD(const Vec xvVec, const Vec wVec, const Vec fBarVec, Vec dAcoudW, word varName, word groupName)
compute dAcoudW
void readVectorBinary(Vec vecIn, const word prefix)
read petsc vector in binary format
void createMLRKSP(const Mat jacMat, const Mat jacPCMat, KSP ksp)
create the multi-level Richardson KSP for solving linear equation
void calcdFdW(const Vec xvVec, const Vec wVec, const word objFuncName, Vec dFdW)
compute dFdW
void calcdFdBC(const Vec xvVec, const Vec wVec, const word objFuncName, const word designVarName, Vec dFdBC)
compute dFdBC
volScalarField & fvSource
void calcdFdBCAD(const Vec xvVec, const Vec wVec, const word objFuncName, const word designVarName, Vec dFdBC)
compute dFdBCAD
void setTimeInstanceField(const label instanceI)
assign primal variables based on the current time instance
void printAllOptions()
call DASolver::printAllOptions
void calcdAcousticsdXvAD(const Vec xvVec, const Vec wVec, const Vec fBarVec, Vec dAcoudW, word varName, word groupName)
compute dAcoudXv
void calcdFdXvAD(const Vec xvVec, const Vec wVec, const word objFuncName, const word designVarName, Vec dFdXv)
compute dFdXv using reverse-mode AD
PetscScalar getForwardADDerivVal(const word objFuncName)
get forwardADDerivVal_
label solvePrimal(const Vec xvVec, Vec wVec)
solve the primal equations
void readMatrixBinary(Mat matIn, const word prefix)
read petsc matrix in binary format
void calcdFdFFD(const Vec xvVec, const Vec wVec, const word objFuncName, const word designVarName, Vec dFdFFD)
compute dFdFFD
label getNLocalPoints() const
void calcdRdWT(const Vec xvVec, const Vec wVec, const label isPC, Mat dRdWT)
compute dRdWT
void initTensorFlowFuncs(pyComputeInterface computeInterface, void *compute, pyJacVecProdInterface jacVecProdInterface, void *jacVecProd)
initialize the call back function pointer
void calcCouplingFaceCoords(const double *volCoords, double *surfCoords)
void getAcousticData(Vec x, Vec y, Vec z, Vec nX, Vec nY, Vec nZ, Vec a, Vec fX, Vec fY, Vec fZ, word groupName)
return the acoustic data values
void calcdForcedXvAD(const Vec xvVec, const Vec wVec, const Vec fBarVec, Vec dForcedW)
compute dForcedXv
label getNLocalAdjointStates() const
return the number of local adjoint states
void calcCouplingFaceCoordsAD(const double *volCoords, const double *seeds, double *product)
calc matrix-vector products for calcCouplingFaceCoords
void calcdForcedStateTPsiAD(const word mode, Vec xvVec, Vec stateVec, Vec psiVec, Vec prodVec)
void calcdRdXvTPsiAD(const Vec xvVec, const Vec wVec, const Vec psi, Vec dRdXvTPsi)
compute dRdXv^T*Psi
double getTimeInstanceObjFunc(const label instanceI, const word objFuncName)
return the value of objective function at the given time instance and name
#define assignValueCheckAD(valA, valB)
void calcdRdAOA(const Vec xvVec, const Vec wVec, const word designVarName, Mat dRdAOA)
compute dRdAOA
void setThermal(double *thermal)
set the thermal (temperature or heat flux) BC to the conjugate heat transfer patches
void setPrimalBoundaryConditions(const label printInfo=1)
void calcdFdAOA(const Vec xvVec, const Vec wVec, const word objFuncName, const word designVarName, Vec dFdAOA)
compute dFdAOA
void calcdRdBC(const Vec xvVec, const Vec wVec, const word designVarName, Mat dRdBC)
compute dRdBC
label getNCouplingPoints()
Get the number of points for the MDO coupling patches.
void(* pyJacVecProdInterface)(const double *, double *, int, const double *, const double *, int, void *)
void destroydRdWTMatrixFree()
destroy matrix free dRdWT
void updateOFMesh(const Vec xvVec)
Update the OpenFoam mesh point coordinates based on the point vector xvVec.
void calcdFdACT(const Vec xvVec, const Vec wVec, const word objFuncName, const word designVarName, const word designVarType, Vec dFdACT)
compute dFdACT
void calcFvSource(const word propName, Vec aForce, Vec tForce, Vec rDist, Vec targetForce, Vec center, Vec fvSource)
calculate the fvSource based on the force profile
void calcdRdACT(const Vec xvVec, const Vec wVec, const word designVarName, const word designVarType, Mat dRdACT)
compute dRdACT
void pointVec2OFMesh(const Vec xvVec) const
assign the points in fvMesh of OpenFOAM based on the point vector
void calcdFvSourcedInputsTPsiAD(const word propName, const word mode, Vec aForce, Vec tForce, Vec rDist, Vec targetForce, Vec center, Vec psi, Vec dFvSource)
void updateDAOption(PyObject *pyOptions)
update the allOptions_ dict in DAOption based on the pyOptions from pyDAFoam
void initializedRdWTMatrixFree(const Vec xvVec, const Vec wVec)
initialize matrix free dRdWT
void setFieldValue4LocalCellI(const word fieldName, const scalar val, const label localCellI, const label compI=0)
set the field value
label getNCouplingFaces()
Get the number of faces for the MDO coupling patches.
void initSolver()
initialize fields and variables
label runFPAdj(const Vec xvVec, const Vec wVec, Vec dFdW, Vec psi)
label getNLocalAdjointBoundaryStates() const
return the number of local adjoint boundary states
void ofResField2ResVec(Vec resVec) const
assign the resVec based on OpenFOAM residual fields
double getObjFuncValue(const word objFuncName)
return the value of objective
void setTimeInstanceVar(const word mode, Mat stateMat, Mat stateBCMat, Vec timeVec, Vec timeIdxVec)
assign the time instance mats to/from the lists in the OpenFOAM layer depending on the mode
void(* pyComputeInterface)(const double *, int, double *, int, void *)
void writeMatrixASCII(const Mat matIn, const word prefix)
write the matrix in ASCII format
void calcdFdACTAD(const Vec xvVec, const Vec wVec, const word objFuncName, const word designVarName, Vec dFdACT)
compute dFdACT
void solveLinearEqn(const KSP ksp, const Vec rhsVec, Vec solVec)
solve the linear equation
void calcdRdBCTPsiAD(const Vec xvVec, const Vec wVec, const Vec psi, const word designVarName, Vec dRdBCTPsi)
compute dRdBC^T*Psi
label getNLocalCells() const
return the number of local cells
void calcdRdFFD(const Vec xvVec, const Vec wVec, const word designVarName, Mat dRdFFD)
compute dRdFFD
void calcdRdActTPsiAD(const Vec xvVec, const Vec wVec, const Vec psi, const word designVarName, Vec dRdActTPsi)
compute dRdAct^T*Psi
void convertMPIVec2SeqVec(const Vec mpiVec, Vec seqVec)
convert the mpi vec to a seq vec
void calcdRdThermalTPsiAD(const double *volCoords, const double *states, const double *thermal, const double *seeds, double *product)
void setFieldValue4GlobalCellI(const word fieldName, const scalar val, const label globalCellI, const label compI=0)
set the field value
void calcdRdAOATPsiAD(const Vec xvVec, const Vec wVec, const Vec psi, const word designVarName, Vec dRdAOATPsi)
compute dRdAOA^T*Psi
void updateOFField(const Vec wVec)
Update the OpenFOAM field values (including both internal and boundary fields) based on the state vec...
const volScalarField & psi
void calcResidualVec(Vec resVec)
calculate the residual and assign it to the resVec vector
void calcForceProfile(Vec center, Vec aForceL, Vec tForceL, Vec rDistL)
void ofField2StateVec(Vec stateVec) const
basically, we call DASolver::ofField2StateVec
void calcdRdWOldTPsiAD(const label oldTimeLevel, const Vec psi, Vec dRdWOldTPsi)
compute dRdWOld^T*Psi