本文整理汇总了C++中CConfig::GetDeform_Linear_Solver_Error方法的典型用法代码示例。如果您正苦于以下问题:C++ CConfig::GetDeform_Linear_Solver_Error方法的具体用法?C++ CConfig::GetDeform_Linear_Solver_Error怎么用?C++ CConfig::GetDeform_Linear_Solver_Error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CConfig
的用法示例。
在下文中一共展示了CConfig::GetDeform_Linear_Solver_Error方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Solve_g
void CSysSolve_b::Solve_g(AD::Tape* tape, AD::CheckpointHandler* data){
/*--- Extract data from the checkpoint handler ---*/
su2double::GradientData *LinSysRes_Indices;
su2double::GradientData *LinSysSol_Indices;
data->getData(LinSysRes_Indices);
data->getData(LinSysSol_Indices);
unsigned long nBlk, nVar, nBlkDomain, size, i;
data->getData(size);
data->getData(nBlk);
data->getData(nVar);
data->getData(nBlkDomain);
CSysMatrix* Jacobian;
data->getData(Jacobian);
CGeometry* geometry;
data->getData(geometry);
CConfig* config;
data->getData(config);
CSysVector LinSysRes_b(nBlk, nBlkDomain, nVar, 0.0);
CSysVector LinSysSol_b(nBlk, nBlkDomain, nVar, 0.0);
su2double Residual;
unsigned long MaxIter = config->GetDeform_Linear_Solver_Iter();
su2double SolverTol = config->GetDeform_Linear_Solver_Error();
/*--- Initialize the right-hand side with the gradient of the solution of the primal linear system ---*/
for (i = 0; i < size; i ++){
su2double::GradientData& index = LinSysSol_Indices[i];
LinSysRes_b[i] = AD::globalTape.getGradient(index);
LinSysSol_b[i] = 0.0;
AD::globalTape.gradient(index) = 0.0;
}
/*--- Set up preconditioner and matrix-vector product ---*/
CPreconditioner* precond = NULL;
switch(config->GetKind_Deform_Linear_Solver_Prec()){
case ILU:
precond = new CILUPreconditioner(*Jacobian, geometry, config);
break;
case JACOBI:
precond = new CJacobiPreconditioner(*Jacobian, geometry, config);
break;
}
CMatrixVectorProduct* mat_vec = new CSysMatrixVectorProductTransposed(*Jacobian, geometry, config);
CSysSolve *solver = new CSysSolve;
/*--- Solve the system ---*/
switch(config->GetKind_Deform_Linear_Solver()){
case FGMRES:
solver->FGMRES_LinSolver(LinSysRes_b, LinSysSol_b, *mat_vec, *precond, SolverTol , MaxIter, &Residual, false);
break;
case BCGSTAB:
solver->BCGSTAB_LinSolver(LinSysRes_b, LinSysSol_b, *mat_vec, *precond, SolverTol, MaxIter, &Residual, false);
break;
case CONJUGATE_GRADIENT:
solver->CG_LinSolver(LinSysRes_b, LinSysSol_b, *mat_vec, *precond, SolverTol, MaxIter, &Residual, false);
break;
}
/*--- Update the gradients of the right-hand side of the primal linear system ---*/
for (i = 0; i < size; i ++){
su2double::GradientData& index = LinSysRes_Indices[i];
AD::globalTape.gradient(index) += SU2_TYPE::GetValue(LinSysSol_b[i]);
}
delete mat_vec;
delete precond;
delete solver;
}