Public Member Functions | Protected Attributes | List of all members
DALaplacianFoam Class Reference
Inheritance diagram for DALaplacianFoam:
Inheritance graph
[legend]
Collaboration diagram for DALaplacianFoam:
Collaboration graph
[legend]

Public Member Functions

 TypeName ("DALaplacianFoam")
 
 DALaplacianFoam (char *argsAll, PyObject *pyOptions)
 
virtual ~DALaplacianFoam ()
 
virtual void initSolver ()
 initialize fields and variables More...
 
virtual label solvePrimal (const Vec xvVec, Vec wVec)
 solve the primal equations More...
 
- Public Member Functions inherited from DASolver
 TypeName ("DASolver")
 Runtime type information. More...
 
 declareRunTimeSelectionTable (autoPtr, DASolver, dictionary,(char *argsAll, PyObject *pyOptions),(argsAll, pyOptions))
 
 DASolver (char *argsAll, PyObject *pyOptions)
 
virtual ~DASolver ()
 
virtual label runFPAdj (const Vec xvVec, const Vec wVec, Vec dFdW, Vec psi)
 solve the adjoint equation using the fixed-point iteration method More...
 
void setTimeInstanceField (const label instanceI)
 assign primal variables based on the current time instance More...
 
scalar getTimeInstanceObjFunc (const label instanceI, const word objFuncName)
 return the value of objective function at the given time instance and name More...
 
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 More...
 
void initOldTimes ()
 initialize the oldTime for all state variables More...
 
void calcdRdWT (const Vec xvVec, const Vec wVec, const label isPC, Mat dRdWT)
 compute dRdWT More...
 
void calcdRdWTPsiAD (const Vec xvVec, const Vec wVec, const Vec psi, Vec dRdWTPsi)
 compute [dRdW]^T*Psi More...
 
void calcdRdWTPsiAD (const label isInit, const Vec psi, Vec dRdWTPsi)
 compute [dRdW]^T*Psi but without updating xvVec and wVec to the OF fields More...
 
void calcdFdW (const Vec xvVec, const Vec wVec, const word objFuncName, Vec dFdW)
 compute dFdW More...
 
void createMLRKSP (const Mat jacMat, const Mat jacPCMat, KSP ksp)
 create a multi-level, Richardson KSP object More...
 
label solveLinearEqn (const KSP ksp, const Vec rhsVec, Vec solVec)
 solve the linear equation given a ksp and right-hand-side vector More...
 
void convertMPIVec2SeqVec (const Vec mpiVec, Vec seqVec)
 convert the mpi vec to a seq vec More...
 
void updateOFField (const Vec wVec)
 Update the OpenFOAM field values (including both internal and boundary fields) based on the state vector wVec. More...
 
void updateOFMesh (const Vec xvVec)
 Update the OpenFoam mesh point coordinates based on the point vector xvVec. More...
 
void updateOFField (const scalar *volCoords)
 Update the OpenFOAM field values (including both internal and boundary fields) based on the state array. More...
 
void updateOFMesh (const scalar *states)
 Update the OpenFoam mesh point coordinates based on the volume point coords array. More...
 
void resetOFSeeds ()
 reset the seeds (gradient to zeros) for all OpenFOAM variables More...
 
void calcdRdBC (const Vec xvVec, const Vec wVec, const word designVarName, Mat dRdBC)
 compute dRdBC More...
 
void calcdFdBC (const Vec xvVec, const Vec wVec, const word objFuncName, const word designVarName, Vec dFdBC)
 compute dFdBC More...
 
void calcdRdBCTPsiAD (const Vec xvVec, const Vec wVec, const Vec psi, const word designVarName, Vec dRdBCTPsi)
 compute dRdBCAD More...
 
void calcdFdBCAD (const Vec xvVec, const Vec wVec, const word objFuncName, const word designVarName, Vec dFdBC)
 compute dFdBCAD More...
 
void calcdRdAOA (const Vec xvVec, const Vec wVec, const word designVarName, Mat dRdAOA)
 compute dRdAOA More...
 
void calcdFdAOA (const Vec xvVec, const Vec wVec, const word objFuncName, const word designVarName, Vec dFdAOA)
 compute dFdAOA More...
 
void calcdRdAOATPsiAD (const Vec xvVec, const Vec wVec, const Vec psi, const word designVarName, Vec dRdAOATPsi)
 compute dRdAOAAD More...
 
void calcdRdFFD (const Vec xvVec, const Vec wVec, const word designVarName, Mat dRdFFD)
 compute dRdFFD More...
 
void calcdFdFFD (const Vec xvVec, const Vec wVec, const word objFuncName, const word designVarName, Vec dFdFFD)
 compute dFdFFD More...
 
void calcdRdACT (const Vec xvVec, const Vec wVec, const word designVarName, const word designVarType, Mat dRdACT)
 compute dRdACT More...
 
void calcdFdACT (const Vec xvVec, const Vec wVec, const word objFuncName, const word designVarName, const word designVarType, Vec dFdACT)
 compute dFdACT More...
 
void calcdRdFieldTPsiAD (const Vec xvVec, const Vec wVec, const Vec psi, const word designVarName, Vec dRdFieldTPsi)
 compute dRdField^T*Psi More...
 
void calcdFdFieldAD (const Vec xvVec, const Vec wVec, const word objFuncName, const word designVarName, Vec dFdField)
 compute dFdField More...
 
void createMLRKSPMatrixFree (const Mat jacPCMat, KSP ksp)
 create a multi-level, Richardson KSP object with matrix-free Jacobians More...
 
void calcdFdWAD (const Vec xvVec, const Vec wVec, const word objFuncName, Vec dFdW)
 compute dFdW using AD More...
 
void calcdRdThermalTPsiAD (const double *volCoords, const double *states, const double *thermal, const double *seeds, double *product)
 
void calcdRdXvTPsiAD (const Vec xvVec, const Vec wVec, const Vec psi, Vec dRdXvTPsi)
 compute dRdXv^T*Psi More...
 
void calcdForcedXvAD (const Vec xvVec, const Vec wVec, const Vec fBarVec, Vec dForcedXv)
 compute dForcedXv More...
 
void calcdAcousticsdXvAD (const Vec xvVec, const Vec wVec, const Vec fBarVec, Vec dForcedXv, word varName, word groupName)
 compute dAcoudXv More...
 
void calcdFdXvAD (const Vec xvVec, const Vec wVec, const word objFuncName, const word designVarName, Vec dFdXv)
 compute dFdXv AD More...
 
void calcdRdActTPsiAD (const Vec xvVec, const Vec wVec, const Vec psi, const word designVarName, Vec dRdActTPsi)
 
void calcdForcedWAD (const Vec xvVec, const Vec wVec, const Vec fBarVec, Vec dForcedW)
 
void calcdAcousticsdWAD (const Vec xvVec, const Vec wVec, const Vec fBarVec, Vec dForcedW, word varName, word groupName)
 
void calcdFdACTAD (const Vec xvVec, const Vec wVec, const word objFuncName, const word designVarName, Vec dFdACT)
 compute dFdACT AD More...
 
void calcdRdWOldTPsiAD (const label oldTimeLevel, const Vec psi, Vec dRdWOldTPsi)
 compute dRdWOld^T*Psi More...
 
void getCouplingPatchList (wordList &patchList, word groupName="NONE")
 return the coupling patch list if any scenario is active on couplingInfo dict otherwise return design surface More...
 
void initializedRdWTMatrixFree (const Vec xvVec, const Vec wVec)
 initialize matrix free dRdWT More...
 
void destroydRdWTMatrixFree ()
 destroy the matrix free dRdWT More...
 
void registerStateVariableInput4AD (const label oldTimeLevel=0)
 register all state variables as the input for reverse-mode AD More...
 
void registerFieldVariableInput4AD (const word fieldName, const word fieldType)
 register field variables as the input for reverse-mode AD More...
 
void registerResidualOutput4AD ()
 register all residuals as the output for reverse-mode AD More...
 
void registerForceOutput4AD (List< scalar > &fX, List< scalar > &fY, List< scalar > &fZ)
 register all force as the ouptut for referse-mod AD More...
 
void registerAcousticOutput4AD (List< scalar > &a)
 register acoustic as the ouptut for referse-mod AD More...
 
void assignVec2ResidualGradient (Vec vecX)
 assign the reverse-mode AD input seeds from vecX to the residuals in OpenFOAM More...
 
void assignSeeds2ResidualGradient (const double *seeds)
 assign the reverse-mode AD input seeds from vecX to the residuals in OpenFOAM More...
 
void assignVec2ForceGradient (Vec fBarVec, List< scalar > &fX, List< scalar > &fY, List< scalar > &fZ)
 assign the reverse-mode AD input seeds from fBarVec to the force vectors in OpenFOAM More...
 
void assignVec2AcousticGradient (Vec fBarVec, List< scalar > &a, label offset, label step)
 assign the reverse-mode AD input seeds from fBarVec to the acoustic vectors in OpenFOAM More...
 
void assignStateGradient2Vec (Vec vecY, const label oldTimeLevel=0)
 set the reverse-mode AD derivatives from the state variables in OpenFOAM to vecY More...
 
void assignFieldGradient2Vec (const word fieldName, const word fieldType, Vec vecY)
 set the reverse-mode AD derivatives from the field variables in OpenFOAM to vecY More...
 
void normalizeGradientVec (Vec vecY)
 normalize the reverse-mode AD derivatives stored in vecY More...
 
void initializeGlobalADTape4dRdWT ()
 initialize the CoDiPack reverse-mode AD global tape for computing dRdWT*psi More...
 
label loop (Time &runTime)
 return whether to loop the primal solution, similar to runTime::loop() except we don't do file IO More...
 
label getGlobalXvIndex (const label idxPoint, const label idxCoord) const
 basically, we call DAIndex::getGlobalXvIndex More...
 
void ofField2StateVec (Vec stateVec) const
 set the state vector based on the latest fields in OpenFOAM More...
 
void stateVec2OFField (const Vec stateVec) const
 assign the fields in OpenFOAM based on the state vector More...
 
void pointVec2OFMesh (const Vec xvVec) const
 assign the points in fvMesh of OpenFOAM based on the point vector More...
 
void ofMesh2PointVec (Vec xvVec) const
 assign the point vector based on the points in fvMesh of OpenFOAM More...
 
void resVec2OFResField (const Vec resVec) const
 assign the OpenFOAM residual fields based on the resVec More...
 
void ofResField2ResVec (Vec resVec) const
 assign the resVec based on OpenFOAM residual fields More...
 
void writeMatrixBinary (const Mat matIn, const word prefix)
 write the matrix in binary format More...
 
void writeMatrixASCII (const Mat matIn, const word prefix)
 write the matrix in ASCII format More...
 
void readMatrixBinary (Mat matIn, const word prefix)
 read petsc matrix in binary format More...
 
void writeVectorASCII (const Vec vecIn, const word prefix)
 write petsc vector in ascii format More...
 
void readVectorBinary (Vec vecIn, const word prefix)
 read petsc vector in binary format More...
 
void writeVectorBinary (const Vec vecIn, const word prefix)
 write petsc vector in binary format More...
 
label getNLocalAdjointStates () const
 return the number of local adjoint states More...
 
label getNLocalAdjointBoundaryStates () const
 return the number of local adjoint boundary states More...
 
label getNLocalCells () const
 return the number of local cells More...
 
label getNLocalPoints () const
 return the number of local points More...
 
void setDAObjFuncList ()
 initialize DASolver::daObjFuncPtrList_ one needs to call this before calling printAllObjFuncs More...
 
void printAllObjFuncs ()
 calculate the values of all objective functions and print them to screen More...
 
label checkMesh () const
 check the mesh quality and return meshOK More...
 
scalar getObjFuncValue (const word objFuncName)
 return the value of the objective function More...
 
void getForces (Vec fX, Vec fY, Vec fZ)
 return the forces of the desired fluid-structure-interaction patches More...
 
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 positions, normals, areas, and forces of the desired acoustic patches More...
 
void getPatchInfo (label &nPoints, label &nFaces, List< word > &patchList)
 return the number of points and faces for MDO patches More...
 
void getForcesInternal (List< scalar > &fX, List< scalar > &fY, List< scalar > &fZ, List< word > &patchList)
 compute the forces of the desired fluid-structure-interation patches More...
 
label getNCouplingFaces ()
 Get the number of faces for the MDO coupling patches. More...
 
label getNCouplingPoints ()
 Get the number of points for the MDO coupling patches. More...
 
void calcCouplingFaceCoords (const scalar *volCoords, scalar *surfCoords)
 return the face coordinates based on vol coords More...
 
void calcCouplingFaceCoordsAD (const double *volCoords, const double *seeds, double *product)
 calc matrix-vector products for calcCouplingFaceCoords More...
 
void getThermal (const scalar *volCoords, const scalar *states, scalar *thermal)
 compute the temperature on the conjugate heat transfer patches More...
 
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 More...
 
void setThermal (scalar *thermal)
 assign temperature values to the conjugate heat transfer patches More...
 
void getAcousticDataInternal (List< scalar > &x, List< scalar > &y, List< scalar > &z, List< scalar > &nX, List< scalar > &nY, List< scalar > &nZ, List< scalar > &a, List< scalar > &fX, List< scalar > &fY, List< scalar > &fZ, List< word > &patchList)
 compute the positions, normals, areas, and forces of the desired acoustic patches More...
 
void calcForceProfile (Vec center, Vec aForceL, Vec tForceL, Vec rDistL)
 calculate the radial profile of the force on the propeller surface More...
 
void calcForceProfileInternal (fvMesh &mesh, const vector &center, scalarList &aForceL, scalarList &tForceL, scalarList &rDistL)
 
void calcdForcedStateTPsiAD (const word mode, Vec xvVec, Vec stateVec, Vec psiVec, Vec prodVec)
 
void calcFvSourceInternal (const word propName, const scalarField &aForce, const scalarField &tForce, const scalarField &rDistList, const scalarList &targetForce, const vector &center, volVectorField &fvSource)
 calculate the fvSource based on the radial force profile More...
 
void calcFvSource (const word propName, Vec aForce, Vec tForce, Vec rDist, Vec targetForce, Vec center, Vec fvSource)
 
void calcdFvSourcedInputsTPsiAD (const word propName, const word mode, Vec aForce, Vec tForce, Vec rDist, Vec targetForce, Vec center, Vec psi, Vec dFvSource)
 
void printAllOptions ()
 print all DAOption More...
 
void calcPrimalResidualStatistics (const word mode, const label writeRes=0)
 calculate the norms of all residuals and print to screen More...
 
void setdXvdFFDMat (const Mat dXvdFFDMat)
 set the value for DASolver::dXvdFFDMat_ More...
 
void setFFD2XvSeedVec (Vec vecIn)
 set the value for DASolver::FFD2XvSeedVec_ More...
 
void updateDAOption (PyObject *pyOptions)
 update the allOptions_ dict in DAOption based on the pyOptions from pyDAFoam More...
 
scalar getPrevPrimalSolTime ()
 get the solution time folder for previous primal solution More...
 
void setFieldValue4GlobalCellI (const word fieldName, const scalar val, const label globalCellI, const label compI=0)
 set the field value More...
 
void setFieldValue4LocalCellI (const word fieldName, const scalar val, const label localCellI, const label compI=0)
 
void updateBoundaryConditions (const word fieldName, const word fieldType)
 update the boundary condition for a field More...
 
void syncDAOptionToActuatorDVs ()
 synchronize the values in DAOption and actuatorDiskDVs_ More...
 
const fvMesh & getMesh ()
 
const Time & getRunTime ()
 return the runTime object More...
 
const DAOptiongetDAOption ()
 get DAOption object More...
 
const DAStateInfogetDAStateInfo ()
 get DAStateInfo object More...
 
const DAIndexgetDAIndex ()
 get DAIndex object More...
 
const DAModelgetDAModel ()
 get DAModel object More...
 
const DAResidualgetDAResidual ()
 get DAResidual object More...
 
const DAFieldgetDAField ()
 get DAField object More...
 
const DALinearEqngetDALinearEqn ()
 get DALinearEqn object More...
 
const DACheckMeshgetDACheckMesh ()
 get DACheckMesh object More...
 
PetscScalar getForwardADDerivVal (const word objFuncName)
 get forwardADDerivVal_ More...
 
void setPrimalBoundaryConditions (const label printInfo=1)
 update the primal state boundary condition based on the primalBC dict More...
 
void calcResidualVec (Vec resVec)
 calculate the residual and assign it to the resVec vector More...
 
void writeFailedMesh ()
 write the failed mesh to disk More...
 
void initTensorFlowFuncs (pyComputeInterface computeInterface, void *compute, pyJacVecProdInterface jacVecProdInterface, void *jacVecProd)
 initialize tensorflow functions and interfaces for callback More...
 

Protected Attributes

autoPtr< volScalarField > TPtr_
 temperature field pointer More...
 
autoPtr< dimensionedScalar > DTPtr_
 DT pointer. More...
 
word mode_ = "None"
 unsteady mode More...
 
- Protected Attributes inherited from DASolver
char * argsAll_
 all the arguments More...
 
PyObject * pyOptions_
 all options in DAFoam More...
 
autoPtr< argList > argsPtr_
 args pointer More...
 
autoPtr< Time > runTimePtr_
 runTime pointer More...
 
autoPtr< fvMesh > meshPtr_
 fvMesh pointer More...
 
autoPtr< DAOptiondaOptionPtr_
 DAOption pointer. More...
 
autoPtr< DAModeldaModelPtr_
 DAModel pointer. More...
 
autoPtr< DAIndexdaIndexPtr_
 DAIndex pointer. More...
 
autoPtr< DAFielddaFieldPtr_
 DAField pointer. More...
 
UPtrList< DAObjFuncdaObjFuncPtrList_
 a list of DAObjFunc pointers More...
 
autoPtr< DACheckMeshdaCheckMeshPtr_
 DACheckMesh object pointer. More...
 
autoPtr< DALinearEqndaLinearEqnPtr_
 DALinearEqn pointer. More...
 
autoPtr< DAResidualdaResidualPtr_
 DAResidual pointer. More...
 
autoPtr< DAStateInfodaStateInfoPtr_
 DAStateInfo pointer. More...
 
HashTable< wordList > stateInfo_
 the stateInfo_ list from DAStateInfo object More...
 
wordList objFuncNames4Adj_
 the list of objective function names that requires adjoint solution More...
 
dictionary psiVecDict_
 the dictionary of adjoint vector (psi) values for all objectives More...
 
dictionary totalDerivDict_
 the dictionary that stores the total derivatives reduced from processors More...
 
autoPtr< OFstream > objFuncAvgHistFilePtr_
 pointer to the objective function file used in unsteady primal solvers More...
 
label nItersObjFuncAvg_ = -9999
 number of iterations since the start of objFunc averaging More...
 
scalarList avgObjFuncValues_
 the averaged objective function values used in unsteady flow More...
 
Mat dRdWTPC_
 the preconditioner matrix for the adjoint linear equation solution More...
 
label nSolveAdjointCalls_ = 0
 how many times the DASolver::solveAdjoint function is called More...
 
Mat dXvdFFDMat_
 the matrix that stores the partials dXv/dFFD computed from the idwarp and pygeo in the pyDAFoam.py More...
 
Vec FFD2XvSeedVec_
 the vector that stores the AD seeds that propagate from FFD to Xv and will be used in forward mode AD More...
 
HashTable< PetscScalar > forwardADDerivVal_
 the derivative value computed by the forward mode primal solution. More...
 
scalar primalMinRes_ = 1e10
 the maximal residual for primal solution More...
 
scalar prevPrimalSolTime_ = -1e10
 the solution time for the previous primal solution More...
 
Mat dRdWTMF_
 matrix-free dRdWT matrix used in GMRES solution More...
 
label globalADTape4dRdWTInitialized = 0
 a flag in dRdWTMatVecMultFunction to determine if the global tap is initialized More...
 
List< List< scalar > > stateAllInstances_
 state variable list for all instances (unsteady) More...
 
List< List< scalar > > stateBoundaryAllInstances_
 state boundary variable list for all instances (unsteady) More...
 
List< dictionary > objFuncsAllInstances_
 objective function for all instances (unsteady) More...
 
List< scalar > runTimeAllInstances_
 the runtime value for all instances (unsteady) More...
 
List< label > runTimeIndexAllInstances_
 the runtime index for all instances (unsteady) More...
 
label nTimeInstances_ = -9999
 number of time instances for hybird adjoint (unsteady) More...
 
scalar periodicity_ = 0.0
 periodicity of oscillating flow variables (unsteady) More...
 
scalar primalMinResTol_ = 0.0
 primal residual tolerance More...
 
label primalMinIters_ = -1
 primal min number of iterations More...
 

Additional Inherited Members

- Static Public Member Functions inherited from DASolver
static autoPtr< DASolverNew (char *argsAll, PyObject *pyOptions)
 
static PetscErrorCode dRdWTMatVecMultFunction (Mat dRdWT, Vec vecX, Vec vecY)
 matrix free matrix-vector product function to compute vecY=dRdWT*vecX More...
 
- Protected Member Functions inherited from DASolver
template<class classType >
void primalResidualControl (const SolverPerformance< classType > &solverP, const label printToScreen, const label printInterval, const word varName)
 setup maximal residual control and print the residual as needed More...
 
label isPrintTime (const Time &runTime, const label printInterval) const
 
label checkResidualTol ()
 check whether the min residual in primal satisfy the prescribed tolerance More...
 
void reduceStateResConLevel (const dictionary &maxResConLv4JacPCMat, HashTable< List< List< word >>> &stateResConInfo) const
 reduce the connectivity level for Jacobian connectivity mat More...
 
void writeAssociatedFields ()
 write associated fields such as relative velocity More...
 
void saveTimeInstanceFieldHybrid (label &timeInstanceI)
 save primal variable to time instance list for hybrid adjoint (unsteady) More...
 
void saveTimeInstanceFieldTimeAccurate (label &timeInstanceI)
 save primal variable to time instance list for time accurate adjoint (unsteady) More...
 

Detailed Description

Definition at line 47 of file DALaplacianFoam.H.

Constructor & Destructor Documentation

◆ DALaplacianFoam()

DALaplacianFoam ( char *  argsAll,
PyObject *  pyOptions 
)

Definition at line 41 of file DALaplacianFoam.C.

◆ ~DALaplacianFoam()

virtual ~DALaplacianFoam ( )
inlinevirtual

Definition at line 73 of file DALaplacianFoam.H.

Member Function Documentation

◆ TypeName()

TypeName ( "DALaplacianFoam"  )

◆ initSolver()

void initSolver ( )
virtual

◆ solvePrimal()

label solvePrimal ( const Vec  xvVec,
Vec  wVec 
)
virtual

Member Data Documentation

◆ TPtr_

autoPtr<volScalarField> TPtr_
protected

temperature field pointer

Definition at line 54 of file DALaplacianFoam.H.

◆ DTPtr_

autoPtr<dimensionedScalar> DTPtr_
protected

DT pointer.

Definition at line 57 of file DALaplacianFoam.H.

◆ mode_

word mode_ = "None"
protected

unsteady mode

Definition at line 60 of file DALaplacianFoam.H.

Referenced by DALaplacianFoam::initSolver(), and DALaplacianFoam::solvePrimal().


The documentation for this class was generated from the following files: