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

Public Member Functions

 TypeName ("DARhoPimpleFoam")
 
 DARhoPimpleFoam (char *argsAll, PyObject *pyOptions)
 
virtual ~DARhoPimpleFoam ()
 
virtual void initSolver ()
 initialize fields and variables More...
 
virtual label solvePrimal ()
 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 (Vec dFdW, Vec psi)
 solve the adjoint equation using the fixed-point iteration method More...
 
virtual label solveAdjointFP (Vec dFdW, Vec psi)
 solve the adjoint equation using the fixed-point iteration method More...
 
void setTime (scalar time, label timeIndex)
 setTime for OF fields More...
 
label getDdtSchemeOrder ()
 get the ddtScheme order More...
 
void printElapsedTime (const Time &runTime, const label printToScreen)
 
void calcdRdWT (const label isPC, Mat dRdWT)
 compute dRdWT More...
 
void updateKSPPCMat (Mat PCMat, KSP ksp)
 Update the preconditioner matrix for the 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 updateOFFields (const scalar *states)
 Update the OpenFOAM field values (including both internal and boundary fields) based on the state array. More...
 
void updateOFMesh (const scalar *volCoords)
 Update the OpenFoam mesh point coordinates based on the volume point coords array. More...
 
void getOFFields (scalar *states)
 assign the state variables from OpenFoam layer to the states array More...
 
void getOFField (const word fieldName, const word fieldType, double *field)
 get a field variable from OF layer More...
 
void getOFMeshPoints (double *points)
 get the flatten mesh points coordinates More...
 
label getInputSize (const word inputName, const word inputType)
 get the array size of an input type More...
 
label getOutputSize (const word outputName, const word outputType)
 get the array size of an output type More...
 
label getInputDistributed (const word inputName, const word inputType)
 get whether the input is distributed among processors More...
 
label getOutputDistributed (const word outputName, const word outputType)
 get whether the output is distributed among processors More...
 
void calcOutput (const word outputName, const word outputType, double *output)
 get whether the output is distributed among processors More...
 
void runColoring ()
 run the coloring solver More...
 
void calcJacTVecProduct (const word inputName, const word inputType, const double *input, const word outputName, const word outputType, const double *seed, double *product)
 calculate the Jacobian-matrix-transposed and vector product for product = [dOutput/dInput]^T * seed More...
 
void setSolverInput (const word inputName, const word inputType, const int inputSize, const double *input, const double *seed)
 
void createMLRKSPMatrixFree (const Mat jacPCMat, KSP ksp)
 create a multi-level, Richardson KSP object with matrix-free Jacobians More...
 
void calcdRdWOldTPsiAD (const label oldTimeLevel, const double *psi, double *dRdWOldTPsi)
 compute dRdWOld^T*Psi More...
 
void calcCouplingFaceCoords (const scalar *volCoords, scalar *surfCoords)
 return the face coordinates based on vol coords 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 ()
 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 deactivateStateVariableInput4AD (const label oldTimeLevel=0)
 deactivate all state variables as the input for reverse-mode AD More...
 
void registerResidualOutput4AD ()
 register all residuals as the output for reverse-mode AD More...
 
void assignVec2ResidualGradient (const double *vecX)
 assign the reverse-mode AD input seeds from vecX to the residuals in OpenFOAM More...
 
void assignStateGradient2Vec (double *vecY, const label oldTimeLevel=0)
 set the reverse-mode AD derivatives from the state variables in OpenFOAM to vecY More...
 
void normalizeGradientVec (double *vecY)
 normalize the reverse-mode AD derivatives stored in vecY More...
 
void normalizeJacTVecProduct (const word inputName, double *product)
 normalize the jacobian vector product that has states as the input such as dFdW and dRdW More...
 
void initializeGlobalADTape4dRdWT ()
 initialize the CoDiPack reverse-mode AD global tape for computing dRdWT*psi More...
 
label hasVolCoordInput ()
 whether the volCoord input is defined More...
 
void initDynamicMesh ()
 resetting internal info in fvMesh, which is needed for multiple primal runs More...
 
label loop (Time &runTime)
 return whether to loop the primal solution, similar to runTime::loop() except we don't do file IO More...
 
void updateInputFieldUnsteady ()
 assign the inputFieldUnsteady values to the OF field vars More...
 
void initInputFieldUnsteady ()
 initialize inputFieldUnsteady from the GlobalVar class More...
 
void meanStatesToStates ()
 assign the mean states values to states More...
 
label getGlobalXvIndex (const label idxPoint, const label idxCoord) const
 basically, we call DAIndex::getGlobalXvIndex 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 setDAFunctionList ()
 initialize DASolver::daFunctionPtrList_ one needs to call this before calling printAllFunctions More...
 
void calcAllFunctions (label print=0)
 calculate the values of all objective functions and print them to screen More...
 
double getTimeOpFuncVal (const word functionName)
 get the function value based on timeOp More...
 
label getFunctionListIndex (const word functionName)
 return the index of a give functionName in daFunctionPtrList_ More...
 
label checkMesh () const
 check the mesh quality and return meshOK More...
 
scalar getdFScaling (const word functionName, const label timeIdx)
 get the scaling factor for dF/d? derivative computation More...
 
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 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 updateBoundaryConditions (const word fieldName, const word fieldType)
 update the boundary condition for a field More...
 
void updateStateBoundaryConditions ()
 update the boundary conditions for all states and intermediate variables More...
 
void calcResiduals (label isPC=0)
 calculate the residuals 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...
 
label getNRegressionParameters (word modelName)
 get the number of regression model parameters More...
 
scalar getRegressionParameter (word modelName, const label idxI)
 get the regression parameter More...
 
void setRegressionParameter (word modelName, const label idxI, scalar val)
 set the regression parameter More...
 
void regressionModelCompute ()
 call the compute method of the regression model More...
 
void setPrimalBoundaryConditions (const label printInfo=1)
 update the primal state boundary condition based on the primalBC dict More...
 
void writeFailedMesh ()
 write the failed mesh to disk More...
 
void readStateVars (scalar timeVal, label oldTimeLevel=0)
 read the state variables from the disk and assign the value to the prescribe time level More...
 
void readMeshPoints (const scalar timeVal)
 read the mesh points from the disk and run movePoints to deform the mesh More...
 
void writeMeshPoints (const double *points, const scalar timeVal)
 write the mesh points to the disk for the given timeVal More...
 
void calcPCMatWithFvMatrix (Mat PCMat, const label turbOnly=0)
 calculate the PC mat using fvMatrix More...
 
void initTensorFlowFuncs (pyComputeInterface computeInterface, void *compute, pyJacVecProdInterface jacVecProdInterface, void *jacVecProd, pySetCharInterface setModelNameInterface, void *setModelName)
 initialize tensorflow functions and interfaces for callback More...
 
void writeAdjStates (const label writeMesh, const wordList &additionalOutput)
 write state variables that are NO_WRITE to disk More...
 
scalar getElapsedClockTime ()
 return the elapsed clock time for testing speed More...
 
scalar getElapsedCpuTime ()
 return the elapsed CPU time for testing speed More...
 
template<class classType >
label validateField (const classType &field)
 check if a field variable has nan More...
 
template<class classType >
label validateVectorField (const classType &field)
 check if a field variable has nan More...
 
label validateStates ()
 check if the state variables have valid values More...
 
void getInitStateVals (HashTable< scalar > &initState)
 calculate the initial value for validate states More...
 
void resetStateVals ()
 reset the states to its initial values this usually happens when we have nan in states More...
 
void writeSensMapSurface (const word name, const double *dFdXs, const double *Xs, const label size, const double timeName)
 write the sensitivity map for all wall surfaces More...
 
void writeSensMapField (const word name, const double *dFdField, const word fieldType, const double timeName)
 write the sensitivity map for the entire field More...
 
scalar getLatestTime ()
 get the latest time solution from the case folder. More...
 
void writeAdjointFields (const word function, const double writeTime, const double *psi)
 write the adjoint variables for all states More...
 

Protected Attributes

autoPtr< pimpleControlDFpimplePtr_
 simple pointer More...
 
autoPtr< fluidThermo > pThermoPtr_
 thermal model More...
 
autoPtr< volScalarField > pPtr_
 pressure field pointer More...
 
autoPtr< volScalarField > rhoPtr_
 density field pointer More...
 
autoPtr< volVectorField > UPtr_
 velocity field pointer More...
 
autoPtr< surfaceScalarField > phiPtr_
 surface flux field pointer More...
 
autoPtr< volScalarField > dpdtPtr_
 pressure time deriv pointer More...
 
autoPtr< volScalarField > KPtr_
 kinetic energy pointer More...
 
autoPtr< compressible::turbulenceModel > turbulencePtr_
 turbulence pointer More...
 
autoPtr< DATurbulenceModeldaTurbulenceModelPtr_
 DATurbulenceModel pointer. More...
 
autoPtr< DAFvSourcedaFvSourcePtr_
 DASource pointer. More...
 
autoPtr< volVectorField > fvSourcePtr_
 fvSource term More...
 
autoPtr< volScalarField > fvSourceEnergyPtr_
 fvSource term for the energy equation More...
 
label hasFvSource_ = 0
 whether to have fvSource term More...
 
scalar cumulativeContErr_ = 0.0
 continuity error More...
 
label reduceIOWriteMesh_ = 0
 whether to write mesh for the reduceIO 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< DAFunctiondaFunctionPtrList_
 a list of DAFunction pointers More...
 
UPtrList< DATimeOpdaTimeOpPtrList_
 a list of DATimeOp pointers More...
 
autoPtr< DACheckMeshdaCheckMeshPtr_
 DACheckMesh object pointer. More...
 
autoPtr< DALinearEqndaLinearEqnPtr_
 DALinearEqn pointer. More...
 
autoPtr< DAResidualdaResidualPtr_
 DAResidual pointer. More...
 
autoPtr< DAStateInfodaStateInfoPtr_
 DAStateInfo pointer. More...
 
autoPtr< DARegressiondaRegressionPtr_
 DARegression pointer. More...
 
autoPtr< DAGlobalVardaGlobalVarPtr_
 DAGlobalVar pointer. More...
 
autoPtr< pointField > points0Ptr_
 the initial points for dynamicMesh without volCoord inputs More...
 
HashTable< wordList > stateInfo_
 the stateInfo_ list from DAStateInfo object 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...
 
scalar primalMinResTol_ = 0.0
 primal residual tolerance More...
 
label printToScreen_ = 0
 whether to print primal information to the screen More...
 
label regModelFail_ = 0
 whether the regModel compute fails More...
 
label printInterval_ = 100
 how frequent do you want to print the primal info default is every 100 steps More...
 
label primalMinIters_ = -1
 primal min number of iterations More...
 
label printIntervalUnsteady_ = 1
 how frequent do you want to print the primal info default is every 100 steps More...
 
List< scalarList > functionTimeSteps_
 a list list that saves the function value for all time steps More...
 
label primalFinalTimeIndex_
 the final time index from the primal solve. for steady state cases it can converge before endTime More...
 
HashTable< scalar > initStateVals_
 initial values for validateStates 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
label isPrintTime (const Time &runTime, const label printInterval) const
 
label checkPrimalFailure ()
 check whether the primal fails based on residual and regression fail flag 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...
 

Detailed Description

Definition at line 52 of file DARhoPimpleFoam.H.

Constructor & Destructor Documentation

◆ DARhoPimpleFoam()

DARhoPimpleFoam ( char *  argsAll,
PyObject *  pyOptions 
)

Definition at line 42 of file DARhoPimpleFoam.C.

◆ ~DARhoPimpleFoam()

virtual ~DARhoPimpleFoam ( )
inlinevirtual

Definition at line 115 of file DARhoPimpleFoam.H.

Member Function Documentation

◆ TypeName()

TypeName ( "DARhoPimpleFoam"  )

◆ initSolver()

void initSolver ( )
virtual

◆ solvePrimal()

label solvePrimal ( )
virtual

Member Data Documentation

◆ pimplePtr_

autoPtr<pimpleControlDF> pimplePtr_
protected

simple pointer

Definition at line 58 of file DARhoPimpleFoam.H.

◆ pThermoPtr_

autoPtr<fluidThermo> pThermoPtr_
protected

thermal model

Definition at line 61 of file DARhoPimpleFoam.H.

◆ pPtr_

autoPtr<volScalarField> pPtr_
protected

pressure field pointer

Definition at line 64 of file DARhoPimpleFoam.H.

◆ rhoPtr_

autoPtr<volScalarField> rhoPtr_
protected

density field pointer

Definition at line 67 of file DARhoPimpleFoam.H.

◆ UPtr_

autoPtr<volVectorField> UPtr_
protected

velocity field pointer

Definition at line 70 of file DARhoPimpleFoam.H.

◆ phiPtr_

autoPtr<surfaceScalarField> phiPtr_
protected

surface flux field pointer

Definition at line 73 of file DARhoPimpleFoam.H.

◆ dpdtPtr_

autoPtr<volScalarField> dpdtPtr_
protected

pressure time deriv pointer

Definition at line 76 of file DARhoPimpleFoam.H.

◆ KPtr_

autoPtr<volScalarField> KPtr_
protected

kinetic energy pointer

Definition at line 79 of file DARhoPimpleFoam.H.

◆ turbulencePtr_

autoPtr<compressible::turbulenceModel> turbulencePtr_
protected

turbulence pointer

Definition at line 82 of file DARhoPimpleFoam.H.

◆ daTurbulenceModelPtr_

autoPtr<DATurbulenceModel> daTurbulenceModelPtr_
protected

◆ daFvSourcePtr_

autoPtr<DAFvSource> daFvSourcePtr_
protected

DASource pointer.

Definition at line 88 of file DARhoPimpleFoam.H.

Referenced by DARhoPimpleFoam::initSolver().

◆ fvSourcePtr_

autoPtr<volVectorField> fvSourcePtr_
protected

fvSource term

Definition at line 91 of file DARhoPimpleFoam.H.

◆ fvSourceEnergyPtr_

autoPtr<volScalarField> fvSourceEnergyPtr_
protected

fvSource term for the energy equation

Definition at line 94 of file DARhoPimpleFoam.H.

◆ hasFvSource_

label hasFvSource_ = 0
protected

whether to have fvSource term

Definition at line 97 of file DARhoPimpleFoam.H.

Referenced by DARhoPimpleFoam::initSolver().

◆ cumulativeContErr_

scalar cumulativeContErr_ = 0.0
protected

continuity error

Definition at line 100 of file DARhoPimpleFoam.H.

◆ reduceIOWriteMesh_

label reduceIOWriteMesh_ = 0
protected

whether to write mesh for the reduceIO

Definition at line 103 of file DARhoPimpleFoam.H.

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


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