예제 #1
0
    /*
     * Tests the delta calculation for each timeout.
     */
    void testDelta()
    {
        MenuContentActivator activator;
        activator.setContentTimer(m_fakeTimeSource);
        activator.setCount(9);
        activator.setBaseIndex(3);

        connect(&activator, &MenuContentActivator::deltaChanged,
                this, &MenuConentActivatorTest::onDeltaChange);
        activator.restart();

        QCOMPARE(m_deltas, QList<int>()); // empty
        QCOMPARE(getIndexList(&activator), QList<int>()); // empty

        m_fakeTimeSource->emitTimeout();
        QCOMPARE(m_deltas, QList<int>() << 1);
        QCOMPARE(getIndexList(&activator), QList<int>() << 4);

        m_fakeTimeSource->emitTimeout();
        QCOMPARE(m_deltas, QList<int>() << 1 << -1);
        QCOMPARE(getIndexList(&activator), QList<int>() << 4 << 2);

        m_fakeTimeSource->emitTimeout();
        QCOMPARE(m_deltas, QList<int>() << 1 << -1 << 2);
        QCOMPARE(getIndexList(&activator), QList<int>() << 4 << 2 << 5);

        m_fakeTimeSource->emitTimeout();
        QCOMPARE(m_deltas, QList<int>() << 1 << -1 << 2 << -2);
        QCOMPARE(getIndexList(&activator), QList<int>() << 4 << 2 << 5 << 1);

        m_fakeTimeSource->emitTimeout();
        QCOMPARE(m_deltas, QList<int>() << 1 << -1 << 2 << -2 << 3);
        QCOMPARE(getIndexList(&activator), QList<int>() << 4 << 2 << 5 << 1 << 6);

        m_fakeTimeSource->emitTimeout();
        QCOMPARE(m_deltas, QList<int>() << 1 << -1 << 2 << -2 << 3 << -3);
        QCOMPARE(getIndexList(&activator), QList<int>() << 4 << 2 << 5 << 1 << 6 << 0);

        m_fakeTimeSource->emitTimeout();
        QCOMPARE(m_deltas, QList<int>() << 1 << -1 << 2 << -2 << 3 << -3 << 4);
        QCOMPARE(getIndexList(&activator), QList<int>() <<  4 << 2 << 5 << 1 << 6 << 0 << 7);

        m_fakeTimeSource->emitTimeout();
        QCOMPARE(m_deltas, QList<int>() << 1 << -1 << 2 << -2 << 3 << -3 << 4 << 5);
        QCOMPARE(getIndexList(&activator), QList<int>() << 4 << 2 << 5 << 1 << 6 << 0 << 7 << 8);

        m_fakeTimeSource->emitTimeout();
        QCOMPARE(m_deltas, QList<int>() << 1 << -1 << 2 << -2 << 3 << -3 << 4 << 5);
        QCOMPARE(getIndexList(&activator), QList<int>() << 4 << 2 << 5 << 1 << 6 << 0 << 7 << 8);
    }
예제 #2
0
void StoreDataVessel::storeDerivativesHighMem( const unsigned& myelem ){
  plumed_dbg_assert( getAction()->derivativesAreRequired() && myelem<getAction()->getFullNumberOfTasks() );
  ActionWithVessel* act=getAction();
  getIndexList( act->getFullNumberOfTasks(), myelem, nspace-1, active_der );

  // Store the values of the components and the derivatives if 
  unsigned nder = act->getNumberOfDerivatives();
  for(unsigned icomp=data_start;icomp<data_start + vecsize;++icomp){
     unsigned ibuf = myelem * ( vecsize*nspace ) + (icomp-data_start)*nspace + 1;
     unsigned kder = act->getFullNumberOfTasks() + myelem * ( nspace - 1 );
     for(unsigned jder=0;jder<active_der[myelem];++jder){
        addToBufferElement( ibuf, act->getElementDerivative(nder*icomp + active_der[ kder ]) );
        kder++; ibuf++;
     }
  }
}
예제 #3
0
void StoreDataVessel::storeDerivativesLowMem( const unsigned& jstore ){
  plumed_dbg_assert( getAction()->derivativesAreRequired() );
  // Store the indexes that have derivatives
  ActionWithVessel* act=getAction();
  unsigned nder = act->getNumberOfDerivatives();
  getIndexList( max_lowmem_stash, jstore, nder, active_der );

  // Stash the derivatives
  for(unsigned icomp=data_start;icomp<data_start + vecsize;++icomp){
     unsigned ibuf = jstore * vecsize * nder + (icomp-data_start)*nder;
     unsigned kder = max_lowmem_stash + jstore*nder;
     for(unsigned jder=0;jder<active_der[jstore];++jder){
        local_derivatives[ibuf] = act->getElementDerivative( nder*icomp + active_der[ kder ] );
        ibuf++; kder++;
     }
  }
}