Пример #1
0
void  SalomeIO::ReadFE(
  hid_t file_id,
  std::vector<std::string> & fe_type_vec,
  hsize_t n_fem_types,
  const std::string  my_mesh_name_dir
    ) 
{
  
    Mesh& mesh = GetMesh();
   
  // Get the element name
  char **el_fem_type = new char*[n_fem_types];
  
  std::vector<int> index(n_fem_types);

    const uint fe_name_nchars = 4;
  
  for(int i=0; i<(int)n_fem_types; i++) {
    
    el_fem_type[i] = new char[fe_name_nchars];
    H5Lget_name_by_idx(file_id,my_mesh_name_dir.c_str(), H5_INDEX_NAME, H5_ITER_INC,i, el_fem_type[i], fe_name_nchars, H5P_DEFAULT);
    std::string temp_i(el_fem_type[i]);
    
    if (mesh.GetDimension() == 3) {
      
          if ( temp_i.compare("HE8") == 0 || 
	       temp_i.compare("H20") == 0 ||  
	       temp_i.compare("H27") == 0 || 
	       temp_i.compare("TE4") == 0 || 
	       temp_i.compare("T10") == 0   ) { index[mesh.GetDimension() -1] = i; fe_type_vec[mesh.GetDimension() -1] = el_fem_type[i];}
          else if  ( temp_i.compare("QU4") == 0 || 
	             temp_i.compare("QU8") == 0 ||  
	             temp_i.compare("QU9") == 0 || 
	             temp_i.compare("TR3") == 0 || 
	             temp_i.compare("TR6") == 0 ) { index[mesh.GetDimension() -1 -1] = i; fe_type_vec[mesh.GetDimension() -1 -1] = el_fem_type[i]; }
          else if  ( temp_i.compare("SE2") == 0 || 
	             temp_i.compare("SE3") == 0 ) { index[mesh.GetDimension() -1 -1 -1] = i; fe_type_vec[mesh.GetDimension() -1 -1 -1] =  el_fem_type[i]; }
	             
    }
    
    else if (mesh.GetDimension() == 2) {
      
           if  (     temp_i.compare("QU4") == 0 || 
	             temp_i.compare("QU8") == 0 ||  
	             temp_i.compare("QU9") == 0 || 
	             temp_i.compare("TR3") == 0 || 
	             temp_i.compare("TR6") == 0    ) {  index[mesh.GetDimension() -1] = i; fe_type_vec[mesh.GetDimension() -1] = el_fem_type[i]; }
          else if  ( temp_i.compare("SE2") == 0 || 
	             temp_i.compare("SE3") == 0 ) {  index[mesh.GetDimension() -1 -1] = i; fe_type_vec[mesh.GetDimension() -1 -1] = el_fem_type[i]; }
     
    }
    
    else if (mesh.GetDimension() == 1) {
               if  ( temp_i.compare("SE2") == 0 || 
	             temp_i.compare("SE3") == 0 ) { index[mesh.GetDimension() -1] = i; fe_type_vec[mesh.GetDimension() -1] = el_fem_type[i];}
    }    
    
  }

  // clean
  for(int i=0; i<(int)n_fem_types; i++) delete[] el_fem_type[i];
  delete[] el_fem_type;
  
  return;
}
Пример #2
0
  BASKER_INLINE
  int Basker<Int, Entry, Exe_Space>::permute_col
  (
   BASKER_MATRIX &M,
   INT_1DARRAY col
   )
  {
    if((M.ncol == 0)||(M.nnz == 0))
      return 0;

    Int n = M.ncol;
    Int nnz = M.nnz;
    //printf("Using n: %d nnz: %d \n", n, nnz);
    INT_1DARRAY temp_p;
    MALLOC_INT_1DARRAY(temp_p, n+1);
    init_value(temp_p, n+1, (Int)0);
    INT_1DARRAY temp_i;
    MALLOC_INT_1DARRAY(temp_i, nnz);
    init_value(temp_i, nnz, (Int)0);
    ENTRY_1DARRAY temp_v;
    MALLOC_ENTRY_1DARRAY(temp_v, nnz);
    init_value(temp_v, nnz, (Entry)0.0);
    //printf("done with init \n");
   
    //Determine column ptr of output matrix
    for(Int j = 0; j < n; j++)
      {
        Int i = col (j);
        temp_p (i+1) = M.col_ptr (j+1) - M.col_ptr (j);
      }
    //Get ptrs from lengths
    temp_p (0) = 0;
  
    for(Int j = 0; j < n; j++)
      {
        temp_p (j+1) = temp_p (j+1) + temp_p (j);
      }
    //copy idxs
    
    for(Int ii = 0; ii < n; ii++)
      {
        Int ko = temp_p (col (ii) );
        for(Int k = M.col_ptr (ii); k < M.col_ptr (ii+1); k++)
          {
            temp_i (ko) = M.row_idx (k);
            temp_v (ko) = M.val (k);
            ko++;
          }
      }
    
    //copy back int A
    for(Int ii=0; ii < n+1; ii++)
      {
        M.col_ptr (ii) = temp_p (ii);
      }
    for(Int ii=0; ii < nnz; ii++)
      {
        M.row_idx (ii) = temp_i (ii);
        M.val (ii) = temp_v (ii);
      }
    FREE_INT_1DARRAY(temp_p);
    FREE_INT_1DARRAY(temp_i);
    FREE_ENTRY_1DARRAY(temp_v);

    return 0;
  }//end permute_col(int)