示例#1
0
static void createHexPri(std::vector<MVertex*> &v, GRegion *to, MElement* source)
{
  int dup[4];
  int j = 0;
  for(int i = 0; i < 4; i++)
    if(v[i] == v[i + 4])
      dup[j++] = i;

  if(j == 2) {
    if(dup[0] == 0 && dup[1] == 1)
      addPrism(v[0], v[3], v[7], v[1], v[2], v[6], to);
    else if(dup[0] == 1 && dup[1] == 2)
      addPrism(v[0], v[1], v[4], v[3], v[2], v[7], to);
    else if(dup[0] == 2 && dup[1] == 3)
      addPrism(v[0], v[3], v[4], v[1], v[2], v[5], to);
    else if(dup[0] == 0 && dup[1] == 3)
      addPrism(v[0], v[1], v[5], v[3], v[2], v[6], to);
    else
      Msg::Error("Uncoherent hexahedron in extrusion of volume %d", to->tag());
  }
  else {
    addHexahedron(v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7], to);
    if(j) Msg::Error("Degenerated hexahedron in extrusion of volume %d", to->tag());
  }
}
示例#2
0
static void createPriPyrTet(std::vector<MVertex*> &v, GRegion *to, MElement* source)
{
  int dup[3];
  int j = 0;
  for(int i = 0; i < 3; i++)
    if(v[i] == v[i + 3])
      dup[j++] = i;

  if(j == 2) {
    if(dup[0] == 0 && dup[1] == 1)
      addTetrahedron(v[0], v[1], v[2], v[5], to);
    else if(dup[0] == 1 && dup[1] == 2)
      addTetrahedron(v[0], v[1], v[2], v[3], to);
    else
      addTetrahedron(v[0], v[1], v[2], v[4], to);
  }
  else if(j == 1) {
    if(dup[0] == 0)
      addPyramid(v[1], v[4], v[5], v[2], v[0], to);
    else if(dup[0] == 1)
      addPyramid(v[0], v[2], v[5], v[3], v[1], to);
    else
      addPyramid(v[0], v[1], v[4], v[3], v[2], to);
  }
  else {
    addPrism(v[0], v[1], v[2], v[3], v[4], v[5], to);
    if(j) Msg::Error("Degenerated prism in extrusion of volume %d", to->tag());
  }
}
// Meshes either a prism or a hexahedral set of mesh vertices in a Transfinite Region with an internal vertex
// that is created here in the function.
void meshTransfElemWithInternalVertex( GRegion *gr, std::vector<MVertex *> v,
                                       std::set< std::pair<MVertex*, MVertex*> > *boundary_diags )
{

  int v_size = v.size();
  int n_lat_tmp;
  if( v_size == 6 )
    n_lat_tmp = 3;
  else if( v_size == 8 )
    n_lat_tmp = 4;
  else{
    Msg::Error("In meshTransfElemWithInternalVertex(), number of element vertices does not equal 6 or 8.");
    return;
  }

  const int n_lat = n_lat_tmp;


  // find vertex node indices for diagonalized faces
  std::vector<int> n1, n2;
  bool found_diags = false;
  int n_size = 0;
  if( n_lat == 3 ){
    n1.assign(n_lat, -1);
    n2.assign(n_lat, -2);
    n_size = 3;
  }
  else if( n_lat == 4 ){
    n1.assign(n_lat+2, -1);
    n2.assign(n_lat+2, -1);
    n_size = 6;
  }

  for( int p = 0; p < n_size; p++ ){
    n1[p] = -p*p-p-1; n2[p] = -p*p-p-2;
    if( p < n_lat || n_lat == 3 ){
      if( v[p] == v[p+n_lat] || v[(p+1)%n_lat] == v[(p+1)%n_lat+n_lat] )
        continue;
      else if( edgeExists( v[p], v[(p+1)%n_lat+n_lat], (*boundary_diags) ) ){
        n1[p] = p; n2[p] = (p+1)%n_lat+n_lat;
        found_diags = true;
      }
      else if( edgeExists( v[p+n_lat], v[(p+1)%n_lat], (*boundary_diags) ) ){
        n1[p] = p+n_lat; n2[p] = (p+1)%n_lat;
        found_diags = true;
      }
    }
    else{
      int add = ( p == n_lat ) ? 0 : n_lat;
      if( edgeExists( v[add], v[add+2], (*boundary_diags) ) ){
        n1[p] = add; n2[p] = add+2;
        found_diags = true;
      }
      else if( edgeExists( v[add+1], v[add+3], (*boundary_diags) ) ){
        n1[p] = add+1; n2[p] = add+3;
        found_diags = true;
      }
    }
  }



  if( !found_diags ){
    if( n_lat == 3 )
      addPrism( v[0], v[1], v[2], v[3], v[4], v[5], gr );
    else if( n_lat ==4 )
      addHexahedron( v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7], gr );
    return;
  }

  // make the internal vertex
  std::vector<double> centroid = QtFindVertsCentroid(v);
  MVertex *v_int = new MVertex(centroid[0], centroid[1], centroid[2], gr);
  gr->mesh_vertices.push_back( v_int );

  // build all pyramids/tetra
  for( int p = 0; p < n_lat; p++ ){
    int p2 = (p+1)%n_lat;
    if( v[p] == v[p+n_lat] && v[p2] == v[p2+n_lat] )
      continue;
    else if( v[p] == v[p+n_lat] || v[p2] == v[p2+n_lat] ){
      MVertex *v_dup = (v[p] == v[p+n_lat]) ? v[p] : v[p2];
      MVertex *v_non_dup = (v_dup == v[p]) ? v[p2] : v[p];
      MVertex *v_non_dup2 = (v_non_dup == v[p]) ? v[p+n_lat] : v[p2+n_lat];
      addTetrahedron( v_dup, v_non_dup, v_non_dup2, v_int, gr);
    }
    else if( n1[p] == p || n2[p] == p ){
      addTetrahedron( v[p], v[p2], v[p2+n_lat], v_int, gr );
      addTetrahedron( v[p], v[p2+n_lat], v[p+n_lat], v_int, gr );
    }
    else if( n1[p] == p+n_lat || n2[p] == p+n_lat ){
      addTetrahedron( v[p], v[p2], v[p+n_lat], v_int, gr );
      addTetrahedron( v[p2], v[p2+n_lat], v[p+n_lat], v_int, gr );
    }
    else
      addPyramid( v[p], v[p2], v[p2+n_lat], v[p+n_lat], v_int, gr );
  }

  if( n_lat == 3){
    // bottom and top
    addTetrahedron( v[0], v[1], v[2], v_int, gr );
    addTetrahedron( v[3], v[5], v[4], v_int, gr );
  }
  else if( n_lat == 4 ){
    for( int p = 4; p < 6; p++ ){
      int add = (p == 4) ? 0 : 4;
      if( n1[p] == 0+add || n2[p] == 0+add  ){
        addTetrahedron( v[add], v[1+add], v[2+add], v_int, gr );
        addTetrahedron( v[add], v[2+add], v[3+add], v_int, gr );
      }
      else if( n1[p] == 1+add || n2[p] == 1+add ){
        addTetrahedron( v[1+add], v[2+add], v[3+add], v_int, gr );
        addTetrahedron( v[1+add], v[3+add], v[add], v_int, gr );
      }
      else
        addPyramid( v[add], v[1+add], v[2+add], v[3+add], v_int, gr );
    }
  }

} // End of meshTransfiniteWithInternalVertex()