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


C++ PatchData::get_element_index方法代码示例

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


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

示例1: evaluate_element

/*!Evaluate the Untangle Beta value  of the MsqMeshEntity pointed to
  by 'element'.*/
bool UntangleBetaQualityMetric::evaluate_element(PatchData &pd,
                                                MsqMeshEntity *element,
                                                 double &fval,
                                                MsqError &err){
  
  double met_vals[MSQ_MAX_NUM_VERT_PER_ENT];
  fval=MSQ_MAX_CAP;
  const size_t* v_i = element->get_vertex_index_array();
  size_t e_ind = pd.get_element_index(element);
    //only 3 temp_vec will be sent to untangle calculator, but the
    //additional vector3Ds may be needed during the calculations
  Vector3D temp_vec[6];
  MsqVertex *vertices=pd.get_vertex_array(err);  MSQ_ERRZERO(err);
  switch(element->get_element_type()){
    case TRIANGLE:
      temp_vec[0]=vertices[v_i[1]]-vertices[v_i[0]];
      temp_vec[2]=vertices[v_i[2]]-vertices[v_i[0]];
        //make relative to equilateral
      temp_vec[1]=((2*temp_vec[2])-temp_vec[0])*MSQ_SQRT_THREE_INV;
      untangle_function_2d(temp_vec,e_ind,pd,fval,err);
      return true;
    case QUADRILATERAL:
      temp_vec[0]=vertices[v_i[1]]-vertices[v_i[0]];
      temp_vec[1]=vertices[v_i[3]]-vertices[v_i[0]];
      untangle_function_2d(temp_vec,e_ind,pd,met_vals[0],err);  MSQ_ERRZERO(err);
      
      temp_vec[0]=vertices[v_i[2]]-vertices[v_i[1]];
      temp_vec[1]=vertices[v_i[0]]-vertices[v_i[1]];
      untangle_function_2d(temp_vec,e_ind,pd,met_vals[1],err);  MSQ_ERRZERO(err);
      
      temp_vec[0]=vertices[v_i[3]]-vertices[v_i[2]];
      temp_vec[1]=vertices[v_i[1]]-vertices[v_i[2]];
      untangle_function_2d(temp_vec,e_ind,pd,met_vals[2],err);  MSQ_ERRZERO(err);
      
      temp_vec[0]=vertices[v_i[0]]-vertices[v_i[3]];
      temp_vec[1]=vertices[v_i[2]]-vertices[v_i[3]];
      untangle_function_2d(temp_vec,e_ind,pd,met_vals[3],err);  MSQ_ERRZERO(err);
      fval=average_metrics(met_vals, 4, err);  MSQ_ERRZERO(err);
  return true;
    case TETRAHEDRON:
      temp_vec[0]=vertices[v_i[1]]-vertices[v_i[0]];
      temp_vec[3]=vertices[v_i[2]]-vertices[v_i[0]];
      temp_vec[4]=vertices[v_i[3]]-vertices[v_i[0]];
        //transform to equilateral tet
      temp_vec[1]=((2*temp_vec[3])-temp_vec[0])/MSQ_SQRT_THREE;
      temp_vec[2]=((3*temp_vec[4])-temp_vec[0]-temp_vec[3])/
        (MSQ_SQRT_THREE*MSQ_SQRT_TWO);
      untangle_function_3d(temp_vec,fval,err);  MSQ_ERRZERO(err);
      return true;
    case HEXAHEDRON:
        //transform to v_i[0]
      temp_vec[0]=vertices[v_i[1]]-vertices[v_i[0]];
      temp_vec[1]=vertices[v_i[3]]-vertices[v_i[0]];
      temp_vec[2]=vertices[v_i[4]]-vertices[v_i[0]];
      untangle_function_3d(temp_vec,met_vals[0],err);  MSQ_ERRZERO(err);
      
      temp_vec[0]=vertices[v_i[2]]-vertices[v_i[1]];
      temp_vec[1]=vertices[v_i[0]]-vertices[v_i[1]];
      temp_vec[2]=vertices[v_i[5]]-vertices[v_i[1]];
      untangle_function_3d(temp_vec,met_vals[1],err);  MSQ_ERRZERO(err);
      
      temp_vec[0]=vertices[v_i[3]]-vertices[v_i[2]];
      temp_vec[1]=vertices[v_i[1]]-vertices[v_i[2]];
      temp_vec[2]=vertices[v_i[6]]-vertices[v_i[2]];
      untangle_function_3d(temp_vec,met_vals[2],err);  MSQ_ERRZERO(err);
      
      temp_vec[0]=vertices[v_i[0]]-vertices[v_i[3]];
      temp_vec[1]=vertices[v_i[2]]-vertices[v_i[3]];
      temp_vec[2]=vertices[v_i[7]]-vertices[v_i[3]];
      untangle_function_3d(temp_vec,met_vals[3],err);  MSQ_ERRZERO(err);
      
      temp_vec[0]=vertices[v_i[7]]-vertices[v_i[4]];
      temp_vec[1]=vertices[v_i[5]]-vertices[v_i[4]];
      temp_vec[2]=vertices[v_i[0]]-vertices[v_i[4]];
      untangle_function_3d(temp_vec,met_vals[4],err);  MSQ_ERRZERO(err);
      
      temp_vec[0]=vertices[v_i[4]]-vertices[v_i[5]];
      temp_vec[1]=vertices[v_i[6]]-vertices[v_i[5]];
      temp_vec[2]=vertices[v_i[1]]-vertices[v_i[5]];
      untangle_function_3d(temp_vec,met_vals[5],err);  MSQ_ERRZERO(err);
      
      temp_vec[0]=vertices[v_i[5]]-vertices[v_i[6]];
      temp_vec[1]=vertices[v_i[7]]-vertices[v_i[6]];
      temp_vec[2]=vertices[v_i[2]]-vertices[v_i[6]];
      untangle_function_3d(temp_vec,met_vals[6],err);  MSQ_ERRZERO(err);
      
      temp_vec[0]=vertices[v_i[6]]-vertices[v_i[7]];
      temp_vec[1]=vertices[v_i[4]]-vertices[v_i[7]];
      temp_vec[2]=vertices[v_i[3]]-vertices[v_i[7]];
      untangle_function_3d(temp_vec,met_vals[7],err);  MSQ_ERRZERO(err);
      fval=average_metrics(met_vals, 8, err);  MSQ_ERRZERO(err);
      return true;
    default:
      MSQ_SETERR(err)("Element of incorrect type sent to "
                      "UntangleBetaQualityMetric",
                      MsqError::NOT_IMPLEMENTED);
      return false;
  }// end switch over element type
//.........这里部分代码省略.........
开发者ID:IllinoisRocstar,项目名称:RocstarBasement,代码行数:101,代码来源:UntangleBetaQualityMetric.cpp

示例2: i_dft_no_barrier_smooth_mesh

  bool I_DFT_NoBarrierSmoother::i_dft_no_barrier_smooth_mesh(
    PatchData &pd, size_t free_index, MsqError &err)
  {
      //get vertex and element arrays
    MsqVertex* verts=pd.get_vertex_array(err); MSQ_ERRFALSE(err);
    MsqMeshEntity* elems=pd.get_element_array(err);MSQ_ERRFALSE(err);
    size_t num_elements = pd.num_elements();
      //matrix to store a map for the given corner
      // (element/vertex combination) that maps the
      //vertex to 0 and the other vertices to 1,2,3
    int local_matrix_map[MSQ_MAX_NUM_VERT_PER_ENT];
    size_t local_matrix_map_length=MSQ_MAX_NUM_VERT_PER_ENT;
    size_t local_matrix_map_used=0;
    Vector3D new_position;
      //will be used as the denominator
    double scale_value = 0.0;
    size_t i, j, k;
      //Z and Z^(t)
    Matrix3D z_mat_transpose;
    Matrix3D z_mat[4];
      //array of Y's... one for each vertex in this corner.
    Matrix3D y_mat[4];
      //c_(j,k) for the vertices
    double c_scalars[4];
      //zeta for this corner
    Vector3D zeta_vector;
    vector<size_t> elems_verts;
      //loop over the two or three dimensions
    for(i=0;i<num_elements;++i) {
        //actually get the map for this corner...
      local_matrix_map_used = elems[i].get_local_matrix_map_about_vertex(
        pd, &verts[free_index],local_matrix_map_length, local_matrix_map,err);
      MSQ_ERRFALSE(err);
      
        //get a vector of the vertex indices for this element
      elems[i].get_vertex_indices(elems_verts);
        //get the W array for this elements
      int elem_idx = pd.get_element_index(&elems[i]);
      const TargetMatrix* W = pd.targetMatrices.get_element_corner_tags(
        &pd, elem_idx, err );      MSQ_ERRFALSE(err);

        //initial c_scalars and zeta_vector to 0.0 and calculate Y for
        //each vertex in the this corner.
      zeta_vector.set( 0.0, 0.0, 0.0);
      for(j=0;j<local_matrix_map_used;++j){
        c_scalars[j]=0.0;
        if(local_matrix_map[j] < 0){
          MSQ_SETERR(err)("Invalid index returned from MsqMeshEntity.\n",
                          MsqError::INVALID_STATE);
          return false;
        }
        inv(z_mat[j],W[local_matrix_map[j]]);
          //inv(z_mat[j], I);
        z_mat_transpose=transpose(z_mat[j]);
        matmult( y_mat[j], z_mat[j], z_mat_transpose);
          //std::cout<<"\n j "<<j<<"\n";
          //std::cout<<"\n"<<y_mat[j]<<"\n";
      }
        //0 case (c_scalars[0])
      for(j=0;j<3;++j){
        for(k=0;k<3;++k){
          c_scalars[0] += ((y_mat[0])[j][k]);
        }
        c_scalars[0] += ((y_mat[j+1])[j][j]);
      }
        //1, 2, and if need 3
      for(j=0;j<3;++j){
        for(k=0;k<3;++k){
          c_scalars[j+1] -= (((y_mat[0])[j][k]) + ((y_mat[j+1])[k][j]));
        }
        c_scalars[j+1] += ((y_mat[((j+2)%3)+1])[((j+1)%3)][((j+2)%3)]);
        c_scalars[j+1] += ((y_mat[((j+1)%3)+1])[((j+2)%3)][((j+1)%3)]);
      }
        //now do zeta_vector
      for(j=0;j<3;++j){
        for(k=0;k<3;++k){
          zeta_vector[j] += ((z_mat[0])[k][j] - (z_mat[k+1])[k][j]);
        }
      }
    
        // accumulate this corner's contribution to the numerator
        // and the denominator...
      for(j=1;j<local_matrix_map_used;++j){
          //std::cout<<"c_k ("<<j<<") ="<<c_scalars[j]<<"\n";
          //std::cout<<"x_k ("<<j<<") ="<<verts[elems_verts[ (size_t) local_matrix_map[j]]]<<"\n";
        new_position+=verts[elems_verts[ (size_t) local_matrix_map[j]]]
          *c_scalars[j];
      }
      new_position+=zeta_vector;
    
        //std::cout<<"c_k (0) ="<<c_scalars[0]<<"\n";
        //std::cout<<"zeta ="<<zeta_vector<<"\n";
      scale_value+=c_scalars[0];
    
    }
    if(scale_value==0.0){
      MSQ_SETERR(err)("Invalid accummulation.\n",
                      MsqError::INVALID_STATE);
      return false;
    }
//.........这里部分代码省略.........
开发者ID:bartlettroscoe,项目名称:trilinos_old_public,代码行数:101,代码来源:I_DFT_NoBarrierSmoother.cpp


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