void GeometryShaderManager::Init() { memset(&constants, 0, sizeof(constants)); // Init any intial constants which aren't zero when bpmem is zero. SetViewportChanged(); SetProjectionChanged(); dirty = true; }
void GeometryShaderManager::Dirty() { SetViewportChanged(); SetProjectionChanged(); SetLinePtWidthChanged(); for (int i = 0; i < 8; i++) SetTexCoordChanged(i); dirty = true; }
/* Save before integration for DiagonalizeMinimize and add test to make sure its not done twice */ bool Integrator::DoStep() { //context->updateContextState(); if( eigenvectors.size() == 0 || stepsSinceDiagonalize % mParameters.rediagFreq == 0 ) { DiagonalizeMinimize(); } stepsSinceDiagonalize++; mMetropolisPE = context->calcForcesAndEnergy( true, true ); IntegrateStep(); SetProjectionChanged( false ); if( !minimize( mParameters.MaximumMinimizationIterations ) ) { if( mParameters.ShouldForceRediagOnMinFail ) { if( mParameters.ShouldProtoMolDiagonalize ) { return false; } else { DiagonalizeMinimize(); } } } //((StepKernel &)( kernel.getImpl() )).updateState( *context ); TimeAndCounterStep(); return true; }
void Integrator::Minimize( const unsigned int max, unsigned int &simpleSteps, unsigned int &quadraticSteps ) { const double eigStore = maxEigenvalue; if( !mParameters.ShouldProtoMolDiagonalize && eigenvectors.size() == 0 ) { computeProjectionVectors(); } SaveStep(); double initialPE = context->calcForcesAndEnergy( true, true ); ( ( StepKernel & )( kernel.getImpl() ) ).setOldPositions(); //context->getPositions(oldPos); // I need to get old positions here simpleSteps = 0; quadraticSteps = 0; for( unsigned int i = 0; i < max; i++ ) { SetProjectionChanged( false ); if( initialPE < mMetropolisPE ) { break; } const double prob = exp(-( 1.0 / ( BOLTZ * temperature )) * ( initialPE - mMetropolisPE )); if( SimTKOpenMMUtilities::getUniformlyDistributedRandomNumber() < prob ) { break; } simpleSteps++; double currentPE = LinearMinimize( initialPE ); if( mParameters.isAlwaysQuadratic || currentPE > initialPE ) { quadraticSteps++; double lambda = 0.0; currentPE = QuadraticMinimize( currentPE, lambda ); if( currentPE > initialPE ) { std::cout << "Quadratic Minimization Failed Energy Test [" << currentPE << ", " << initialPE << "] - Forcing Rediagonalization" << std::endl; if( !mParameters.ShouldProtoMolDiagonalize ) computeProjectionVectors(); break; } else { if( mParameters.ShouldForceRediagOnQuadraticLambda && lambda < 1.0 / maxEigenvalue ) { std::cout << "Quadratic Minimization Failed Lambda Test [" << lambda << ", " << 1.0 / maxEigenvalue << "] - Forcing Rediagonalization" << std::endl; if( !mParameters.ShouldProtoMolDiagonalize ) computeProjectionVectors(); break; } } } if( mParameters.ShouldUseMetropolisMinimization ) { if( currentPE < mMetropolisPE ) { break; } const double prob = exp(-( 1.0 / ( BOLTZ * temperature )) * ( currentPE - mMetropolisPE )); if( SimTKOpenMMUtilities::getUniformlyDistributedRandomNumber() < prob ) { break; } } else { const double diff = initialPE - currentPE; if( diff < getMinimumLimit() && diff >= 0.0 ) { break; } if( diff > 0.0 ) { SaveStep(); initialPE = currentPE; } else { RevertStep(); context->calcForcesAndEnergy( true, false ); maxEigenvalue *= 2; } } } mSimpleMinimizations += simpleSteps; mQuadraticMinimizations += quadraticSteps; maxEigenvalue = eigStore; }