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


C++ ExoII_Read::Open方法代码示例

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


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

示例1: Compute_FileId_Maps

void Compute_FileId_Maps(INT *&node_map, INT *&elmt_map, ExoII_Read<INT> &file1,
                         ExoII_Read<INT> &file2)
{
  // Compute map of nodes and elements in file1 to nodes and elements in file2
  // Use the internal exodus node and element number maps in file1 and file2 to
  // do the matching.  Currently assume (and verify) that number of nodes and
  // elements match in the two files.

  SMART_ASSERT(file1.Open());
  SMART_ASSERT(file2.Open());

  {
    size_t num_nodes = file1.Num_Nodes();
    SMART_ASSERT(num_nodes == file2.Num_Nodes());

    node_map = new INT[num_nodes];
    SMART_ASSERT(node_map != nullptr);
    file1.Load_Node_Map();
    file2.Load_Node_Map();
    const INT *node_id_map1 = file1.Get_Node_Map();
    const INT *node_id_map2 = file2.Get_Node_Map();

    if (!internal_compute_maps(node_map, node_id_map1, node_id_map2, num_nodes, "node")) {
      delete[] node_map;
      node_map = nullptr;
    }
  }

  {
    size_t num_elmts = file1.Num_Elmts();
    SMART_ASSERT(num_elmts == file2.Num_Elmts());
    elmt_map = new INT[num_elmts];
    SMART_ASSERT(elmt_map != nullptr);
    file1.Load_Elmt_Map();
    file2.Load_Elmt_Map();
    const INT *elem_id_map1 = file1.Get_Elmt_Map();
    const INT *elem_id_map2 = file2.Get_Elmt_Map();

    if (!internal_compute_maps(elmt_map, elem_id_map1, elem_id_map2, num_elmts, "element")) {
      delete[] elmt_map;
      elmt_map = nullptr;
    }
  }
}
开发者ID:jbcarleton,项目名称:seacas,代码行数:44,代码来源:map.C

示例2: Compute_Maps

void Compute_Maps(INT*& node_map, INT*& elmt_map,
                  ExoII_Read<INT>& file1, ExoII_Read<INT>& file2)
{
  SMART_ASSERT(file1.Open());
  SMART_ASSERT(file2.Open());
  
  size_t num_nodes = file1.Num_Nodes();
  size_t num_elmts = file1.Num_Elmts();
  int dim = file1.Dimension();
  
  //  ********************  elements  ********************  //

  // Load global ids (0-offset) into id array.
  auto  id = new INT[num_elmts];
  {for (size_t e = 0; e < num_elmts; ++e) id[e] = e;}
  
  // Get map storage.
  node_map = new INT[num_nodes];  SMART_ASSERT(node_map != nullptr);
  {for (size_t i = 0; i < num_nodes; ++i) node_map[i] = -1; }
  elmt_map = new INT[num_elmts];  SMART_ASSERT(elmt_map != nullptr);
  
  // Create storage for midpoints.
  double *x2 = nullptr, *y2 = nullptr, *z2 = nullptr;
  x2 = new double[num_elmts];  SMART_ASSERT(x2 != nullptr);
  if (dim > 1) { y2 = new double[num_elmts];  SMART_ASSERT(y2 != nullptr); }
  if (dim > 2) { z2 = new double[num_elmts];  SMART_ASSERT(z2 != nullptr); }
  
  // Load coordinates for file 2 and get pointers to them.
  file2.Load_Nodal_Coordinates();
  const double* x2_f = (double*)file2.X_Coords();
  const double* y2_f = (double*)file2.Y_Coords();
  const double* z2_f = (double*)file2.Z_Coords();
  
  // Load connectivities for all blocks in second file.
  file2.Load_Elmt_Block_Descriptions();
  
  {
    // Compute midpoints of each element and place into x,y,z arrays.
    size_t num_blocks = file2.Num_Elmt_Blocks(),
      num_elmts_in_block,
      num_nodes_per_elmt,
      e = 0;
    double sum_x, sum_y, sum_z;
    for (size_t b = 0; b < num_blocks; ++b)
      {
	const Exo_Block<INT>* block = file2.Get_Elmt_Block_by_Index(b);
	num_elmts_in_block = block->Size();
	num_nodes_per_elmt = block->Num_Nodes_per_Elmt();
	for (size_t i = 0; i < num_elmts_in_block; ++i)
	  {
	    const INT* conn = block->Connectivity(i);  // Connectivity for element i.
	    sum_x = 0.0; sum_y = 0.0; sum_z = 0.0;
	    for (size_t j = 0; j < num_nodes_per_elmt; ++j) {
	      sum_x += x2_f[ conn[j] - 1 ];
	      if (dim > 1) sum_y += y2_f[ conn[j] - 1 ];
	      if (dim > 2) sum_z += z2_f[ conn[j] - 1 ];
	    }
	    x2[e] = sum_x / (double)num_nodes_per_elmt;
	    if (dim > 1) y2[e] = sum_y / (double)num_nodes_per_elmt;
	    if (dim > 2) z2[e] = sum_z / (double)num_nodes_per_elmt;
      
	    ++e;
	  }
      }
  }
  
  // Sort by x value.
  index_qsort(x2, id, num_elmts);
  
#if 0
  std::cout << "******************  elmts  ******************** " << std::endl;
  {for (size_t i = 0; i < num_elmts; ++i)
      std::cout << i << ")\t"
		<< x2[id[i]] << "\t"
		<< y2[id[i]] << "\t"
		<< z2[id[i]] << "\t" << id[i] << std::endl;}
  std::cout << "******************  elmts  ******************** " << std::endl;
#endif  
  //  Load and get nodal coordinates for first file.
  file1.Load_Nodal_Coordinates();
  const double* x1_f = (double*)file1.X_Coords();
  const double* y1_f = (double*)file1.Y_Coords();
  const double* z1_f = (double*)file1.Z_Coords();
  
  // Cannot ignore the comparisons, so make sure the coord_tol_type
  // is not -1 which is "ignore"
  TOLERANCE_TYPE_enum save_tolerance_type = interface.coord_tol.type;
  if (save_tolerance_type == IGNORE)
    interface.coord_tol.type = ABSOLUTE;

  // Match elmts in first file to their corresponding elmts in second.
  size_t num_blocks = file1.Num_Elmt_Blocks();
  size_t num_elmts_in_block;
  size_t num_nodes_per_elmt;
  size_t e1 = 0;
  size_t e2 = 0;
  INT sort_idx;
  double mid_x, mid_y, mid_z;

  for (size_t b = 0; b < num_blocks; ++b)
//.........这里部分代码省略.........
开发者ID:Russell-Jones-OxPhys,项目名称:Trilinos,代码行数:101,代码来源:map.C

示例3: Compute_Partial_Maps

void Compute_Partial_Maps(INT*& node_map, INT*& elmt_map,
			  ExoII_Read<INT>& file1, ExoII_Read<INT>& file2)
{
  SMART_ASSERT(file1.Open());
  SMART_ASSERT(file2.Open());
  
  size_t num_nodes1 = file1.Num_Nodes();
  size_t num_elmts1 = file1.Num_Elmts();

  //size_t num_nodes2 = file2.Num_Nodes();
  size_t num_elmts2 = file2.Num_Elmts();
  int dim = file1.Dimension();
  SMART_ASSERT(dim == file2.Dimension());
  
//  ********************  elements  ********************  //

  // Load global ids (0-offset) into id array.
  auto  id2 = new INT[num_elmts2];
  {for (size_t e = 0; e < num_elmts2; ++e) id2[e] = e;}
  
  // Get map storage.
  node_map = new INT[num_nodes1];  SMART_ASSERT(node_map != nullptr);
  {for (size_t i = 0; i < num_nodes1; ++i) node_map[i] = -1; }
  elmt_map = new INT[num_elmts1];  SMART_ASSERT(elmt_map != nullptr);
  {for (size_t i = 0; i < num_elmts1; ++i) elmt_map[i] = -1; }

  // Create storage for midpoints.
  double *x2 = nullptr, *y2 = nullptr, *z2 = nullptr;
  x2 = new double[num_elmts2];  SMART_ASSERT(x2 != nullptr);
  if (dim > 1) { y2 = new double[num_elmts2];  SMART_ASSERT(y2 != nullptr); }
  if (dim > 2) { z2 = new double[num_elmts2];  SMART_ASSERT(z2 != nullptr); }
  
  // Load coordinates for file 2 and get pointers to them.
  file2.Load_Nodal_Coordinates();
  const double* x2_f = (double*)file2.X_Coords();
  const double* y2_f = (double*)file2.Y_Coords();
  const double* z2_f = (double*)file2.Z_Coords();
  
  // Load connectivities for all blocks in second file.
  file2.Load_Elmt_Block_Descriptions();
  
  {
  // Compute midpoints of each element and place into x,y,z arrays.
  size_t num_blocks2 = file2.Num_Elmt_Blocks(),
      num_elmts_in_block,
      num_nodes_per_elmt,
      e = 0;
  double sum_x, sum_y, sum_z;
  for (size_t b = 0; b < num_blocks2; ++b)
  {
    const Exo_Block<INT>* block = file2.Get_Elmt_Block_by_Index(b);
    num_elmts_in_block = block->Size();
    num_nodes_per_elmt = block->Num_Nodes_per_Elmt();
    for (size_t i = 0; i < num_elmts_in_block; ++i)
    {
      const INT* conn = block->Connectivity(i);  // Connectivity for element i.
      sum_x = 0.0; sum_y = 0.0; sum_z = 0.0;
      for (size_t j = 0; j < num_nodes_per_elmt; ++j) {
        sum_x += x2_f[ conn[j] - 1 ];
        if (dim > 1) sum_y += y2_f[ conn[j] - 1 ];
        if (dim > 2) sum_z += z2_f[ conn[j] - 1 ];
      }
      x2[e] = sum_x / (double)num_nodes_per_elmt;
      if (dim > 1) y2[e] = sum_y / (double)num_nodes_per_elmt;
      if (dim > 2) z2[e] = sum_z / (double)num_nodes_per_elmt;
      
      ++e;
    }
  }
  }
  
  // Sort by x value.
  index_qsort(x2, id2, num_elmts2);
  
#if 0
  std::cout << "******************  elmts  ******************** " << std::endl;
  {for (size_t i = 0; i < num_elmts; ++i)
    std::cout << i << ")\t"
	      << x2[id[i]] << "\t"
	      << y2[id[i]] << "\t"
	      << z2[id[i]] << "\t" << id[i] << std::endl;}
  std::cout << "******************  elmts  ******************** " << std::endl;
#endif  
  //  Load and get nodal coordinates for first file.
  file1.Load_Nodal_Coordinates();
  const double* x1_f = (double*)file1.X_Coords();
  const double* y1_f = (double*)file1.Y_Coords();
  const double* z1_f = (double*)file1.Z_Coords();
  
  // Cannot ignore the comparisons, so make sure the coord_tol_type
  // is not -1 which is "ignore"
  TOLERANCE_TYPE_enum save_tolerance_type = interface.coord_tol.type;
  if (save_tolerance_type == IGNORE)
    interface.coord_tol.type = ABSOLUTE;

  // Match elmts in first file to their corresponding elmts in second.
  size_t num_blocks1 = file1.Num_Elmt_Blocks();
  size_t num_elmts_in_block;
  size_t num_nodes_per_elmt;
  size_t e1 = 0;
//.........这里部分代码省略.........
开发者ID:Russell-Jones-OxPhys,项目名称:Trilinos,代码行数:101,代码来源:map.C


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