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


C++ Options::Tol方法代码示例

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


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

示例1: main

int main(int argc, char** argv) {
  const int buf_len = 512;
  int   rc, docheck, print_flag;
  char fname[buf_len], outname[buf_len], statefname[buf_len];
  FILE *F, *FS;
  mytm TM;
  
  // These are permanent stores and we need to worry about memory management
  Subcatchment *SUB = NULL;
  NameStore    *NODE_NAMES;
  SMap         HASH;

  if ( argc < 3 ) {
    printf("Usage: %s <netlistfile> <state file name>\n", argv[0]);
    printf("       %s -checkonly <netlistfile>\n", argv[0]);
    return (-1);
  }
  
  docheck = 0;
  if ( argc == 3 && strcmp(argv[1],"-checkonly")==0 ) {
    docheck = 1;
    strncpy(fname, argv[2], buf_len);
  } else {
    docheck = 0;
    strncpy(fname, argv[1], buf_len);
    strncpy(statefname, argv[2], buf_len);
  }

  if ( (F=fopen(fname, "r")) == NULL ) {
    printf("Bummer: unable to open netlist file %s\n", argv[1]);
    return (-1);
  }

  PrintHeader(stdout);

  /* allocate the subcatchment and the topograph */
  SUB = new Subcatchment(0);
  NODE_NAMES = new NameStore();
  
  // default option values
  OPT.Alpha() = 0.8;
  OPT.Beta() = 1.03;
  OPT.HT() =  1e-3;
  OPT.MinDT() = 0.001;
  OPT.SSTol() = 5e-8;
  OPT.Tol() = 1e-6;
  OPT.EpsilonA() =  1e-4;
  OPT.DebugLevel() = 0;

  rc = read_spt_from_file(F, SUB, NODE_NAMES, &HASH, stdout); // also modifies OPT and
                                                              // STAT in the global
                                                              // namespace
  // save the netlist file
  STAT.SetInFile( get_basename( fname ) );

  if (rc < 0 ) goto out;  // there is error!

  // do a topo check
  rc = SUB->TopologyCheck();

  if (rc < 0 ) {
    SUB->TopoPrintErrMsg(stdout, "== tchk ==", NODE_NAMES->Store() );
    goto out;
  }

  // quit if docheck == 1
  if ( OPT.CheckOnly() == 1 || docheck==1 ) {
    printf("The connectivity of the given netlist appears to be correct\n");
    goto out;
  }

  // make solver
  SUB->MakeSolver( SUB->GetNumNodes() );

  //  SUB->InitSolutions();
  FS = fopen( statefname, "r");
  rc = ERROR; 

  if ( FS ) { 
    const int perf_check=0;  // force to ignore the check. Could be dangerous!
    rc = SUB->LoadSteadyStateFromFile(FS, perf_check);
    SUB->CopyXpToXtm1();
    SUB->CopyXpToX();

    if ( rc == OK ) printf("[II]: Loaded states from \"%s\"\n", statefname );
    fclose(FS);
  } 

  // steady solve, two phases
  if ( rc!=OK) { // either no state file, or state file is not good
    rc = SUB->SteadySolve(600, 600, 2*OPT.Tol());
    if (rc<0) {
      fprintf(stdout,"[EE]: first phase of steady-state solve failed\n");
      goto out;
    }

    rc = SUB->SteadySolve(25.0, 45, 45, OPT.Tol() );
    if (rc<0) {
      fprintf(stdout,"[EE]: second phase of steady-state solve failed\n");
      goto out;
//.........这里部分代码省略.........
开发者ID:Kevin-M-Smith,项目名称:SPRNT,代码行数:101,代码来源:spt_rolling.cpp


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