当前位置: 首页>>代码示例>>C++>>正文


C++ TaskManager::initialize方法代码示例

本文整理汇总了C++中TaskManager::initialize方法的典型用法代码示例。如果您正苦于以下问题:C++ TaskManager::initialize方法的具体用法?C++ TaskManager::initialize怎么用?C++ TaskManager::initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TaskManager的用法示例。


在下文中一共展示了TaskManager::initialize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char* argv[]){
	
    /* ****************************************************************
      * the first part looks exactly like in the last example. 
      * ***************************************************************/

    //first set up the random number generator
    RandomNumberGenerators randomNumbers;
    randomNumbers.seedAll();
    
    //now set up the system
    typedef LOKI_TYPELIST_3(FeatureMoleculesIO,FeatureBox,FeatureBondset<>) Features;
    typedef ConfigureSystem<VectorInt3,Features> Config;
    typedef Ingredients<Config> MyIngredients;
    MyIngredients mySystem;

    mySystem.setBoxX(64);
    mySystem.setBoxY(64);
    mySystem.setBoxZ(64);
    
    mySystem.setPeriodicX(true);
    mySystem.setPeriodicY(true);
    mySystem.setPeriodicZ(true);
    
    mySystem.modifyBondset().addBFMclassicBondset();
    
    mySystem.synchronize(mySystem);
    
    
    /* ****************************************************************
      * as compared to the previous example, we now don't create the 
      * particles by hand, but we use an updater for this in the 
      * task manager. the advantage of this approach is that you can 
      * reuse this updater in different programs, so you don't have to
      * write the code for creating particles every time. 
      * 
      * we want the particles to be created once before the simulation.
      * so we have to tell the task manager this when adding the 
      * updater. this is done by giving the number 0 as execution 
      * frequency, as shown below.
      * the largest part of the code below is exactly the same as in the
      * previous example.
      * ***************************************************************/
    
    //create the task manager
    TaskManager taskmanager;
    
    //add the ex5updater, which creates the particles
    //again, the addUpdater function takes two arguments. The first one
    //is a pointer to the updater, and the second one is the execution
    //frequency. here we use 0 as frequency, because we want the updater
    //to be executed only once at the beginning.
    //what would happen, if you set a number different from 0? 
    uint32_t numberOfParticles=100;
    taskmanager.addUpdater(new Ex5Updater<MyIngredients>(mySystem,numberOfParticles),0);
    

    //add the simulator
    //here we set the frequency to one, because we want to execute it in every
    //circle
    taskmanager.addUpdater(new 
    UpdaterSimpleSimulator<MyIngredients,MoveLocalSc>(mySystem,1000),1);

    //the following two analyzers are the same as in the last example:
    //on top of this, we add a third one, which is the ex5analyzer
    //written for this example.
    
    //add the file output, the trajectory file name will be "polymer.bfm"
    taskmanager.addAnalyzer(new 
    AnalyzerWriteBfmFile<MyIngredients>("polymer.bfm",mySystem),1);
    
    //add the radius of gyration calculation. we execute this only 
    //every 10th time
    taskmanager.addAnalyzer(new 
    AnalyzerRadiusOfGyration<MyIngredients>(mySystem,"polymer"),10);

    //now add the ex5analyzer. execute it every second circle
    std::string outputFilename("ex5output.dat");
    taskmanager.addAnalyzer(new Ex5Analyzer<MyIngredients>(mySystem,outputFilename),2);
    
    //as before, we initialize and run the task manager, and cleanup afterwards
    taskmanager.initialize();
    taskmanager.run(10000);
    taskmanager.cleanup();
    
    return 0;
}
开发者ID:hrabbel,项目名称:LeMonADE,代码行数:87,代码来源:ex5main.cpp


注:本文中的TaskManager::initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。