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


C++ SolutionPtr::readFromFile方法代码示例

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


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

示例1: main


//.........这里部分代码省略.........
  {
    u_1 = varFactory.fieldVar("u_1");
    u_2 = varFactory.fieldVar("u_2");
    u_3 = varFactory.fieldVar("rho");
    u_4 = varFactory.fieldVar("T");
  }

  // test fxns
  VarPtr tau1 = varFactory.testVar("\\tau_1",HDIV);
  VarPtr tau2 = varFactory.testVar("\\tau_2",HDIV);
  VarPtr tau3 = varFactory.testVar("\\tau_3",HDIV);
  VarPtr v1 = varFactory.testVar("v_1",HGRAD);
  VarPtr v2 = varFactory.testVar("v_2",HGRAD);
  VarPtr v3 = varFactory.testVar("v_3",HGRAD);
  VarPtr v4 = varFactory.testVar("v_4",HGRAD);

  ////////////////////////////////////////////////////////////////////
  // CREATE BILINEAR FORM PTR AND MESH
  ////////////////////////////////////////////////////////////////////

  BFPtr bf = Teuchos::rcp( new BF(varFactory) ); // initialize bilinear form

  // create a pointer to a new mesh:
  //  Teuchos::RCP<Mesh> mesh = Mesh::buildQuadMesh(domainPoints, horizontalCells, verticalCells, bf, H1Order, H1Order+pToAdd, useTriangles);
  Teuchos::RCP<Mesh> mesh = MeshUtilities::buildRampMesh(rampHeight,bf, H1Order, H1Order+pToAdd);
  //  mesh->setPartitionPolicy(Teuchos::rcp(new ZoltanMeshPartitionPolicy("HSFC")));
  mesh->setPartitionPolicy(Teuchos::rcp(new ZoltanMeshPartitionPolicy("REFTREE")));
  MeshInfo meshInfo(mesh); // gets info like cell measure, etc

  // for writing ref history to file
  Teuchos::RCP< RefinementHistory > refHistory = Teuchos::rcp( new RefinementHistory );
  mesh->registerObserver(refHistory);


  ////////////////////////////////////////////////////////////////////
  // CREATE SOLUTION OBJECT
  ////////////////////////////////////////////////////////////////////

  BCPtr nullBC = Teuchos::rcp((BC*)NULL);
  RHSPtr nullRHS = Teuchos::rcp((RHS*)NULL);
  IPPtr nullIP = Teuchos::rcp((IP*)NULL);
  SolutionPtr backgroundFlow = Teuchos::rcp(new Solution(mesh, nullBC, nullRHS, nullIP) );
  SolutionPtr prevTimeFlow = Teuchos::rcp(new Solution(mesh, nullBC, nullRHS, nullIP) );
  Teuchos::RCP<Solution> solution = Teuchos::rcp(new Solution(mesh, nullBC, nullRHS, nullIP));
  int enrichDegree = 2; // just for kicks.
  if (rank==0)
    cout << "enriching cubature by " << enrichDegree << endl;
  solution->setCubatureEnrichmentDegree(enrichDegree); // double cubature enrichment
  if (reportTimingResults)
  {
    solution->setReportTimingResults(true);
  }

  mesh->registerSolution(solution);
  mesh->registerSolution(backgroundFlow); // u_t(i)
  mesh->registerSolution(prevTimeFlow); // u_t(i-1)

  // for loading refinement history
  if (replayFile.length() > 0)
  {
    RefinementHistory refHistory;
    replayFile = dir + replayFile;
    refHistory.loadFromFile(replayFile);
    refHistory.playback(mesh);
    int numElems = mesh->numActiveElements();
    if (rank==0)
    {
      double minSideLength = meshInfo.getMinCellSideLength() ;
      cout << "after replay, num elems = " << numElems << " and min side length = " << minSideLength << endl;
    }
  }
  if (solnLoadFile.length() > 0)
  {
    std::ostringstream ss;
    //    ss << dir <<  "solution_" << solnLoadFile;
    //    solution->readFromFile(ss.str());
    ss.str("");
    ss << dir << "backgroundFlow_" << solnLoadFile;
    backgroundFlow->readFromFile(ss.str());
    ss.str("");
    ss << dir << "prevTimeFlow_" << solnLoadFile;
    prevTimeFlow->readFromFile(ss.str());
  }

  ////////////////////////////////////////////////////////////////////
  // PSEUDO-TIME SOLVE STRATEGY
  ////////////////////////////////////////////////////////////////////

  VTKExporter exporter(solution, mesh, varFactory);
  VTKExporter backgroundFlowExporter(backgroundFlow, mesh, varFactory);


  if (rank==0)
  {
    exporter.exportSolution("dU");
    backgroundFlowExporter.exportSolution("U");
  }

  return 0;
}
开发者ID:CamelliaDPG,项目名称:Camellia,代码行数:101,代码来源:PlateVisualizer.cpp


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