PetscErrorCode ShellApplyML(PC pc,Vec x,Vec y) { PetscErrorCode ierr; ML_Epetra::MultiLevelPreconditioner *mlp = 0; void* ctx; ierr = PCShellGetContext(pc,&ctx); CHKERRQ(ierr); mlp = (ML_Epetra::MultiLevelPreconditioner*)ctx; #endif /* Wrap x and y as Epetra_Vectors. */ PetscScalar *xvals,*yvals; ierr = VecGetArray(x,&xvals);CHKERRQ(ierr); Epetra_Vector epx(View,mlp->OperatorDomainMap(),xvals); ierr = VecGetArray(y,&yvals);CHKERRQ(ierr); Epetra_Vector epy(View,mlp->OperatorRangeMap(),yvals); /* Apply ML. */ mlp->ApplyInverse(epx,epy); /* Clean up and return. */ ierr = VecRestoreArray(x,&xvals);CHKERRQ(ierr); ierr = VecRestoreArray(y,&yvals);CHKERRQ(ierr); return 0; } /*ShellApplyML*/
std::vector<NS_CORE KpdZac> CalcKinCharacteristics::calcKpdZacStepen( const NS_CORE InternalGearRatios& intRatios, const std::vector<NS_CORE W>& w, const std::vector<NS_CORE N>& n ) { std::vector<NS_CORE KpdZac> ret; NS_CORE Log::warning( w.size() != n.size(), "Wrong size", NS_CORE Log::eWarningImportance::CRITICAL, HERE ); const int size = w.size(); const int planetaryGearsCount = NS_CORE Singletons::getInstance()->getInitialData()._numberOfPlanetaryGears; ret.resize( size ); for ( int i = 0; i < size; i++ ) { for ( NS_CORE GearSetNumber gearSet( 1 ); gearSet.getValue() <= planetaryGearsCount; ++gearSet ) { NS_CORE Element sun( NS_CORE eMainElement::SUN_GEAR, gearSet ); NS_CORE Element epy( NS_CORE eMainElement::EPICYCLIC_GEAR, gearSet ); NS_CORE Element car( NS_CORE eMainElement::CARRIER, gearSet ); double kpdA = 1; double kpdB = 1; const double ksi_a_c = 0.02; const double ksi_b_c = 0.01; const auto k = intRatios[gearSet.getValue() - 1]; if ( n[i].at( sun ) == '0' && n[i].at( epy ) == '0' && n[i].at( car ) == '0' ) { kpdA = 1; kpdB = 1; } else if ( w[i].at( sun ) && w[i].at( epy ) && w[i].at( car ) ) { NS_CORE Element sun( NS_CORE eMainElement::SUN_GEAR, gearSet ); NS_CORE Element epy( NS_CORE eMainElement::EPICYCLIC_GEAR, gearSet ); IFunction_p func = Function::create( k, w[i], n[i], gearSet ); kpdB = SolveFunctionDiv::create()->calc( func, 0.8f, 1.0f ); kpdA = 2 * kpdB - 1; kpdA = pow( kpdA, -Function::sign( n[i].at( sun ) ) ); kpdB = pow( kpdB, -Function::sign( n[i].at( epy ) ) ); } else if ( !w[i].at( sun ) && w[i].at( epy ) && w[i].at( car ) ) { double kpdSum = 1 - 1.0f / ( 1 + k.getValue() ) * ( ksi_a_c + ksi_b_c ); kpdA = 1 / kpdSum; kpdB = pow( kpdSum, -Function::sign( n[i].at( epy ) ) ); } else if ( w[i].at( sun ) && !w[i].at( epy ) && w[i].at( car ) ) { double kpdSum = 1 - k.getValue() / ( 1.0f + k.getValue() ) * ( ksi_a_c + ksi_b_c ); kpdA = pow( kpdSum, -Function::sign( n[i].at( sun ) ) ); kpdB = 1 / kpdSum; } else if ( w[i].at( sun ) && w[i].at( epy ) && !w[i].at( car ) ) { kpdA = 1 - ksi_a_c; kpdB = 1 - ksi_b_c; kpdA = pow( kpdA, -Function::sign( n[i].at( sun ) ) ); kpdB = pow( kpdB, -Function::sign( n[i].at( epy ) ) ); } else if (!w[i].at(sun) && !w[i].at(epy) && !w[i].at(car)) { //empty gear kpdA = 1; kpdB = 1; } else { NS_CORE Log::warning( true, "Can't calculate KPD", NS_CORE Log::CRITICAL, HERE ); } ret[i][gearSet]._kpdA = kpdA; ret[i][gearSet]._kpdB = kpdB; } } return ret; }