Пример #1
0
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;
    }
  }
}
Пример #2
0
bool Compare_Maps(ExoII_Read<INT>& file1, ExoII_Read<INT>& file2, const INT *node_map, const INT *elmt_map, bool partial_flag)
{
  // Check whether the node and element number maps from both file1
  // and file2 match which indicates that we are comparing the same
  // element and node in each file.

  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();
  
  // NOTE: file1 maps are already loaded...
  file2.Load_Node_Map();
  file2.Load_Elmt_Map();

  const INT *node_id_map1 = file1.Get_Node_Map();
  const INT *elem_id_map1 = file1.Get_Elmt_Map();

  const INT *node_id_map2 = file2.Get_Node_Map();
  const INT *elem_id_map2 = file2.Get_Elmt_Map();

  bool diff = false;
  size_t warn_count = 0;
  
  if (node_map != nullptr) {
    // There is a map between file1 and file2, but all nodes are
    // used in both files.
    for (size_t i=0; i < num_nodes1; i++) {
      if (node_id_map1[i] != node_id_map2[node_map[i]]) {
	if (!(node_id_map2[node_map[i]] == 0 && partial_flag)) { // Don't output diff if non-matched and partial
	  std::cout << "exodiff: WARNING .. The local node " << i+1 << " with global id " << node_id_map1[i]
		    << " in file1 has the global id " << node_id_map2[node_map[i]]
		    << " in file2.\n";
	  diff = true;
	  warn_count++;
	  if (warn_count > 100) {
	    std::cout << "exodiff: WARNING .. Too many warnings, skipping remainder...\n";
	    break;
	  }
	}
      }
    }
  } else {
    // No node mapping between file1 and file2 -- do a straight compare.
    for (size_t i=0; i < num_nodes1; i++) {
      if (node_id_map1[i] != node_id_map2[i]) {
	if (!(node_id_map2[i] == 0 && partial_flag)) { // Don't output diff if non-matched and partial
	  std::cout << "exodiff: WARNING .. The local node " << i+1 << " with global id " << node_id_map1[i]
		    << " in file1 has the global id " << node_id_map2[i]
		    << " in file2.\n";
	  diff = true;
	  warn_count++;
	  if (warn_count > 100) {
	    std::cout << "exodiff: WARNING .. Too many warnings, skipping remainder...\n";
	    break;
	  }
	}
      }
    }
  }

  warn_count = 0;
  if (elmt_map != nullptr) {
    // There is a map between file1 and file2, but all elements are
    // used in both files.
    for (size_t i=0; i < num_elmts1; i++) {
      if (elem_id_map1[i] != elem_id_map2[elmt_map[i]]) {
	if (!(elem_id_map2[elmt_map[i]] == 0 && partial_flag)) { // Don't output diff if non-matched and partial
	  std::cout << "exodiff: WARNING .. The local element " << i+1 << " with global id " << elem_id_map1[i]
		    << " in file1 has the global id " << elem_id_map2[elmt_map[i]]
		    << " in file2.\n";
	  diff = true;
	  warn_count++;
	  if (warn_count > 100) {
	    std::cout << "exodiff: WARNING .. Too many warnings, skipping remainder...\n";
	    break;
	  }
	}
      }
    }
  } else {
    // No element mapping between file1 and file2 -- do a straight compare.
    for (size_t i=0; i < num_elmts1; i++) {
      if (elem_id_map1[i] != elem_id_map2[i]) {
	if (!(elem_id_map2[i] == 0 && partial_flag)) { // Don't output diff if non-matched and partial
	  std::cout << "exodiff: WARNING .. The local element " << i+1 << " with global id " << elem_id_map1[i]
		    << " in file1 has the global id " << elem_id_map2[i]
		    << " in file2.\n";
	  diff = true;
	  warn_count++;
	  if (warn_count > 100) {
	    std::cout << "exodiff: WARNING .. Too many warnings, skipping remainder...\n";
	    break;
	  }
	}
      }
    }
  }
  file2.Free_Node_Map();
  file2.Free_Elmt_Map();

  if (diff) std::cout << std::endl;
  return diff;
}