Go to the documentation of this file.
   44     autoPtr<DASolver> DASolverPtr_;
 
   60         DASolverPtr_->initSolver();
 
   66         return DASolverPtr_->solvePrimal();
 
   73         return DASolverPtr_->getInputSize(inputName, inputType);
 
   77         const word outputName,
 
   78         const word outputType)
 
   80         return DASolverPtr_->getOutputSize(outputName, outputType);
 
   84         const word outputName,
 
   85         const word outputType,
 
   88         DASolverPtr_->calcOutput(outputName, outputType, output);
 
   95         return DASolverPtr_->getInputDistributed(inputName, inputType);
 
   99         const word outputName,
 
  100         const word outputType)
 
  102         return DASolverPtr_->getOutputDistributed(outputName, outputType);
 
  107         const word inputName,
 
  108         const word inputType,
 
  110         const word outputName,
 
  111         const word outputType,
 
  115         DASolverPtr_->calcJacTVecProduct(
 
  126         const word inputName,
 
  127         const word inputType,
 
  132         DASolverPtr_->setSolverInput(
 
  143         DASolverPtr_->runColoring();
 
  151         DASolverPtr_->calcdRdWT(isPC, dRdWT);
 
  159         DASolverPtr_->updateKSPPCMat(PCMat, ksp);
 
  167         DASolverPtr_->createMLRKSPMatrixFree(jacPCMat, ksp);
 
  173         DASolverPtr_->initializedRdWTMatrixFree();
 
  179         DASolverPtr_->destroydRdWTMatrixFree();
 
  188         return DASolverPtr_->solveLinearEqn(ksp, rhsVec, solVec);
 
  193         const label oldTimeLevel,
 
  197         DASolverPtr_->calcdRdWOldTPsiAD(oldTimeLevel, 
psi, dRdWOldTPsi);
 
  203 #if !defined(CODI_ADR) && !defined(CODI_ADF) 
  204         DASolverPtr_->updateOFFields(states);
 
  207         scalar* statesArray = 
new scalar[localSize];
 
  208         for (label i = 0; i < localSize; i++)
 
  210             statesArray[i] = states[i];
 
  212         DASolverPtr_->updateOFFields(statesArray);
 
  213         delete[] statesArray;
 
  220         DASolverPtr_->getOFMeshPoints(points);
 
  226 #if !defined(CODI_ADR) && !defined(CODI_ADF) 
  227         DASolverPtr_->getOFFields(states);
 
  230         scalar* statesArray = 
new scalar[localSize];
 
  231         DASolverPtr_->getOFFields(statesArray);
 
  232         for (label i = 0; i < localSize; i++)
 
  234             states[i] = statesArray[i].value();
 
  236         delete[] statesArray;
 
  242         const word fieldName,
 
  243         const word fieldType,
 
  246         DASolverPtr_->getOFField(fieldName, fieldType, field);
 
  252 #if !defined(CODI_ADR) && !defined(CODI_ADF) 
  253         DASolverPtr_->updateOFMesh(volCoords);
 
  256         scalar* volCoordsArray = 
new scalar[localSize];
 
  257         for (label i = 0; i < localSize; i++)
 
  259             volCoordsArray[i] = volCoords[i];
 
  261         DASolverPtr_->updateOFMesh(volCoordsArray);
 
  262         delete[] volCoordsArray;
 
  268         const label idxPoint,
 
  269         const label idxCoord)
 const 
  271         return DASolverPtr_->getGlobalXvIndex(idxPoint, idxCoord);
 
  277         return DASolverPtr_->checkMesh();
 
  283         return DASolverPtr_->getNLocalPoints();
 
  289         return DASolverPtr_->getNLocalAdjointStates();
 
  295         return DASolverPtr_->getNLocalAdjointBoundaryStates();
 
  301         return DASolverPtr_->getNLocalCells();
 
  307         return DASolverPtr_->getTimeOpFuncVal(functionName);
 
  313         double returnVal = 0.0;
 
  319         const double* volCoords,
 
  322 #if !defined(CODI_ADR) && !defined(CODI_ADF) 
  323         DASolverPtr_->calcCouplingFaceCoords(volCoords, surfCoords);
 
  326         FatalErrorIn(
"calcCouplingFaceCoords") << 
"should not call this func in AD mode!" 
  327                                                << abort(FatalError);
 
  333         double returnVal = 0.0;
 
  341         double returnVal = 0.0;
 
  349         return DASolverPtr_->getNRegressionParameters(modelName);
 
  355         DASolverPtr_->printAllOptions();
 
  361         return DASolverPtr_->hasVolCoordInput();
 
  367         DASolverPtr_->updateDAOption(pyOptions);
 
  373         double returnVal = 0.0;
 
  380         DASolverPtr_->writeFailedMesh();
 
  388         DASolverPtr_->readStateVars(timeVal, timeLevel);
 
  394         DASolverPtr_->readMeshPoints(timeVal);
 
  400         DASolverPtr_->writeMeshPoints(points, timeVal);
 
  406         DASolverPtr_->calcPCMatWithFvMatrix(PCMat, turbOnly);
 
  412         DASolverPtr_->setTime(time, timeIndex);
 
  418         return DASolverPtr_->getDdtSchemeOrder();
 
  424 #if !defined(CODI_ADR) && !defined(CODI_ADF) 
  425         return DASolverPtr_->getRunTime().endTime().value();
 
  427         FatalErrorIn(
"getEndTime") << 
"should not call this func in AD mode!" 
  428                                    << abort(FatalError);
 
  434 #if !defined(CODI_ADR) && !defined(CODI_ADF) 
  435         return DASolverPtr_->getRunTime().deltaT().value();
 
  437         FatalErrorIn(
"getDeltaT") << 
"should not call this func in AD mode!" 
  438                                   << abort(FatalError);
 
  443         const word fieldName,
 
  444         const word fieldType)
 
  446         DASolverPtr_->updateBoundaryConditions(fieldName, fieldType);
 
  452         DASolverPtr_->updateStateBoundaryConditions();
 
  458         DASolverPtr_->calcPrimalResidualStatistics(
mode, 0);
 
  463         DASolverPtr_->setPrimalBoundaryConditions(printInfo);
 
  470         return DASolverPtr_->runFPAdj(dFdW, 
psi);
 
  477         return DASolverPtr_->solveAdjointFP(dFdW, 
psi);
 
  489         DASolverPtr_->initTensorFlowFuncs(
 
  490             computeInterface, compute, jacVecProdInterface, jacVecProd, setModelNameInterface, setModelName);
 
  496         const double writeTime,
 
  499         DASolverPtr_->writeAdjointFields(
function, writeTime, 
psi);
 
  508         const double timeName)
 
  510         DASolverPtr_->writeSensMapSurface(name, dFdXs, Xs, size, timeName);
 
  516         const double* dFdField,
 
  517         const word fieldType,
 
  518         const double timeName)
 
  520         DASolverPtr_->writeSensMapField(name, dFdField, fieldType, timeName);
 
  526         double latestTime = 0.0;
 
  527 #if !defined(CODI_ADR) && !defined(CODI_ADF) 
  528         latestTime = DASolverPtr_->getLatestTime();
 
  530         scalar tmp = DASolverPtr_->getLatestTime();
 
  531         latestTime = tmp.getValue();
 
  539         DASolverPtr_->meanStatesToStates();
 
  545         DASolverPtr_->updateInputFieldUnsteady();
 
  
void writeMeshPoints(const double *points, const scalar timeVal)
write the mesh points to the disk for the given timeVal
void calcPrimalResidualStatistics(const word mode)
Calculate the mean, max, and norm2 for all residuals and print it to screen.
double getEndTime()
return the endTime
void updateBoundaryConditions(const word fieldName, const word fieldType)
update the boundary condition for a field
label getGlobalXvIndex(const label idxPoint, const label idxCoord) const
basically, we call DAIndex::getGlobalXvIndex
void getOFFields(double *states)
Assign the OpenFOAM field values to the states array.
label checkMesh() const
basically, we call DASolver::checkMesh
double getPrevPrimalSolTime()
get the solution time folder for previous primal solution
virtual ~DASolvers()
Destructor.
void writeAdjointFields(const word function, const double writeTime, const double *psi)
write the adjoint variables for all states
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
void createMLRKSPMatrixFree(const Mat jacPCMat, KSP ksp)
create a multi-level, Richardson KSP object with matrix-free Jacobians
void initializedRdWTMatrixFree()
initialize matrix free dRdWT
label getNRegressionParameters(word modelName)
get the number of regression model parameters
double getElapsedClockTime()
return the elapsed clock time for testing speed
void setSolverInput(const word inputName, const word inputType, const int inputSize, const double *input, const double *seed)
label solveLinearEqn(const KSP ksp, const Vec rhsVec, Vec solVec)
solve the linear equation
void(* pySetCharInterface)(const char *, void *)
void getOFField(const word fieldName, const word fieldType, double *field)
get a field variable from OF layer
void getOFMeshPoints(double *points)
get the flatten mesh points coordinates
void meanStatesToStates()
assign the mean states values to states
double getElapsedCpuTime()
return the elapsed CPU time for testing speed
label getDdtSchemeOrder()
get the ddtScheme order
void runColoring()
run the coloring solver
void initTensorFlowFuncs(pyComputeInterface computeInterface, void *compute, pyJacVecProdInterface jacVecProdInterface, void *jacVecProd, pySetCharInterface setModelNameInterface, void *setModelName)
initialize the call back function pointer
label getOutputDistributed(const word outputName, const word outputType)
label runFPAdj(Vec dFdW, Vec psi)
void printAllOptions()
call DASolver::printAllOptions
void readMeshPoints(const scalar timeVal)
read the mesh points from the disk and run movePoints to deform the mesh
label solveAdjointFP(Vec dFdW, Vec psi)
double getLatestTime()
get the latest solution time
label getNLocalPoints() const
void updateInputFieldUnsteady()
assign the inputFieldUnsteady values to the OF field vars
void calcCouplingFaceCoords(const double *volCoords, double *surfCoords)
label getOutputSize(const word outputName, const word outputType)
void updateOFFields(const double *states)
Update the OpenFOAM field values (including both internal and boundary fields) based on the states ar...
void calcdRdWT(const label isPC, Mat dRdWT)
compute dRdWT
label getNLocalAdjointStates() const
return the number of local adjoint states
void writeSensMapField(const word name, const double *dFdField, const word fieldType, const double timeName)
write the sensitivity map for the entire field
void calcOutput(const word outputName, const word outputType, double *output)
#define assignValueCheckAD(valA, valB)
label getInputSize(const word inputName, const word inputType)
void updateOFMesh(const double *volCoords)
Update the OpenFoam mesh point coordinates based on the point vector xvVec.
void calcPCMatWithFvMatrix(Mat PCMat, const label turbOnly)
calculate the PC mat using fvMatrix
void updateKSPPCMat(Mat PCMat, KSP ksp)
Update the preconditioner matrix for the ksp object.
double getdFScaling(const word functionName, const label timeIdx)
get the scaling factor for dF/d? computation
void setPrimalBoundaryConditions(const label printInfo=1)
double getDeltaT()
return the deltaT
void updateStateBoundaryConditions()
update the boundary conditions for all states and intermediate variables
void(* pyJacVecProdInterface)(const double *, double *, int, const double *, const double *, int, void *)
void destroydRdWTMatrixFree()
destroy matrix free dRdWT
void readStateVars(scalar timeVal, label timeLevel=0)
read the state variables from the disk and assign the value to the prescribe time level
void updateDAOption(PyObject *pyOptions)
update the allOptions_ dict in DAOption based on the pyOptions from pyDAFoam
void initSolver()
initialize fields and variables
label getNLocalAdjointBoundaryStates() const
return the number of local adjoint boundary states
void setTime(scalar time, label timeIndex)
setTime for OF fields
label hasVolCoordInput()
whether the volCoord input is defined
void(* pyComputeInterface)(const double *, int, double *, int, void *)
label solvePrimal()
solve the primal equations
label getNLocalCells() const
return the number of local cells
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
double getTimeOpFuncVal(const word functionName)
return the value of objective based on timeOp
label getInputDistributed(const word inputName, const word inputType)
void calcdRdWOldTPsiAD(const label oldTimeLevel, const double *psi, double *dRdWOldTPsi)
compute dRdWOld^T*Psi
const volScalarField & psi