Changeset 418:cfb70bb62bed

Show
Ignore:
Timestamp:
11/03/2012 01:56:16 AM (7 months ago)
Author:
Andreas Schaefer <gentryx@…>
Branch:
default
Children:
419:79940a8687ac, 423:06105dbc4269
Message:

Steerer interface for HiParSimulator? now operational and tested

Location:
src
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • src/io/teststeerer.h

    r357 r418  
    3636            return; 
    3737        } 
    38          
     38 
    3939        for (typename Region<DIM>::Iterator i = validRegion.begin(); 
    4040             i != validRegion.end(); 
  • src/parallelization/hiparsimulator/updategroup.h

    r417 r418  
    2222class UpdateGroup 
    2323{ 
     24    friend class HiParSimulatorTest; 
    2425    friend class UpdateGroupPrototypeTest; 
    2526    friend class UpdateGroupTest; 
     
    121122        } 
    122123 
     124        // add external PatchProviders last to allow them to override 
     125        // the local ghost zone providers (a.k.a. PatchLink::Source). 
    123126        for (typename PatchProviderVec::iterator i = patchProvidersGhost.begin(); 
    124127             i != patchProvidersGhost.end();  
  • src/parallelization/test/parallel_mpi_1/hiparsimulatortest.h

    r417 r418  
    55#include <libgeodecomp/io/mocksteerer.h> 
    66#include <libgeodecomp/io/mockwriter.h> 
     7#include <libgeodecomp/io/teststeerer.h> 
    78#include <libgeodecomp/io/parallelmemorywriter.h> 
    89#include <libgeodecomp/io/testinitializer.h> 
     
    2223{ 
    2324public: 
     25    typedef GridBase<TestCell<2>, 2> GridBaseType; 
    2426    // fixme: rename types a la "MyFoobar" to "FoobarType" 
    2527    typedef HiParSimulator<TestCell<2>, StripingPartition<2> > SimulatorType; 
    2628    typedef ParallelMemoryWriter<TestCell<2> > MemoryWriterType; 
    27     typedef MockSteerer<TestCell<2> > SteererType; 
     29    typedef MockSteerer<TestCell<2> > MockSteererType; 
     30    typedef TestSteerer<2 > TestSteererType; 
    2831 
    2932    void setUp() 
     
    101104    { 
    102105        std::stringstream events; 
    103         s->addSteerer(new SteererType(5, &events)); 
     106        s->addSteerer(new MockSteererType(5, &events)); 
    104107        s->run(); 
    105108        s.reset();         
     
    107110        std::stringstream expected; 
    108111        expected << "created, period = 5\n"; 
    109         for (int i = 20; i <= 200; i += 5) { 
     112        for (int i = 25; i <= 200; i += 5) { 
     113            expected << "nextStep(" << i << ")\n"; 
    110114            expected << "nextStep(" << i << ")\n"; 
    111115        } 
     
    113117 
    114118        TS_ASSERT_EQUALS(events.str(), expected.str()); 
     119    } 
     120 
     121    void testSteererFunctionality() 
     122    { 
     123        s->addSteerer(new TestSteererType(5, 25, 4711 * 27)); 
     124        s->run(); 
     125 
     126        const Region<2> *region = &s->updateGroup->partitionManager->ownRegion(); 
     127        const GridBaseType *grid = &s->updateGroup->grid(); 
     128        int cycle = 200 * 27 + 4711 * 27; 
     129 
     130        TS_ASSERT_TEST_GRID_REGION( 
     131            GridBaseType,  
     132            *grid,  
     133            *region,  
     134            cycle); 
    115135    } 
    116136 
  • src/parallelization/test/parallel_mpi_4/hiparsimulatortest.h

    r376 r418  
    22#include <cxxtest/TestSuite.h> 
    33#include <sstream> 
     4#include <libgeodecomp/io/mocksteerer.h> 
    45#include <libgeodecomp/io/mockwriter.h> 
     6#include <libgeodecomp/io/teststeerer.h> 
    57#include <libgeodecomp/io/parallelmemorywriter.h> 
    68#include <libgeodecomp/io/testinitializer.h> 
     
    2022{ 
    2123public: 
     24    typedef GridBase<TestCell<2>, 2> GridBaseType; 
    2225    typedef HiParSimulator<TestCell<2>, ZCurvePartition<2> > SimulatorType; 
    2326    typedef ParallelMemoryWriter<TestCell<2> > MemoryWriterType; 
     27    typedef MockSteerer<TestCell<2> > MockSteererType; 
     28    typedef TestSteerer<2 > TestSteererType; 
    2429 
    2530    void setUp() 
     
    106111    } 
    107112 
     113    void testSteererCallback() 
     114    { 
     115        std::stringstream events; 
     116        s->addSteerer(new MockSteererType(5, &events)); 
     117        s->run(); 
     118        s.reset();         
     119 
     120        std::stringstream expected; 
     121        expected << "created, period = 5\n"; 
     122        for (int i = 25; i <= 100; i += 5) { 
     123            expected << "nextStep(" << i << ")\n"; 
     124            expected << "nextStep(" << i << ")\n"; 
     125        } 
     126        expected << "deleted\n"; 
     127 
     128        TS_ASSERT_EQUALS(events.str(), expected.str()); 
     129    } 
     130 
     131    void testSteererFunctionality() 
     132    { 
     133        s->addSteerer(new TestSteererType(5, 25, 4711 * 27)); 
     134        s->run(); 
     135 
     136        const Region<2> *region = &s->updateGroup->partitionManager->ownRegion(); 
     137        const GridBaseType *grid = &s->updateGroup->grid(); 
     138        int cycle = 100 * 27 + 4711 * 27; 
     139 
     140        TS_ASSERT_TEST_GRID_REGION( 
     141            GridBaseType,  
     142            *grid,  
     143            *region,  
     144            cycle); 
     145    } 
     146 
    108147private: 
    109148    boost::shared_ptr<SimulatorType> s; 
     
    119158}; 
    120159 
    121 }; 
    122 }; 
     160} 
     161}