void SculptMeshFactory::addNodeSets(STK_Interface & mesh) const
{
    mesh.beginModification();

    struct MeshStorageStruct *mss = get_sculpt_mesh();
    int num_node_sets  = mss->num_node_sets;
 

    if (num_node_sets) {
      int *node_set_id = new int[num_node_sets];
      int *num_nodes_in_node_set = new int[num_node_sets];
      int *num_df_in_node_set = new int[num_node_sets];
      int **node_set_nodes = new int*[num_node_sets];
      double **node_set_df = new double*[num_node_sets];

      for(int ict = 0; ict < num_node_sets; ict ++){
        node_set_id[ict] = mss->node_set_id[ict];
        num_nodes_in_node_set[ict] = mss->num_nodes_in_node_set[ict];
        num_df_in_node_set[ict] = mss->num_df_in_node_set[ict];
      }

      for(int i = 0; i < num_node_sets; i++) {
        node_set_nodes[i] = new int[num_nodes_in_node_set[i]];
        node_set_df[i] = NULL;
        if(num_nodes_in_node_set[i]) {
          for(int nct = 0; nct < num_nodes_in_node_set[i];nct ++){
            node_set_nodes[i][nct] = mss->node_set_nodes[i][nct];
          }
        }
      }
    

      for(int i = 0; i < num_node_sets; i++) {
    
        std::stringstream nodesetName;
        nodesetName << "Nodeset-" << mss->node_set_id[i];
        stk_classic::mesh::Part * nodeset = mesh.getNodeset(nodesetName.str());

        for( int j = 0; j < num_nodes_in_node_set[i]; j++ )
        {
           int node_id = node_set_nodes[i][j];
           Teuchos::RCP<stk_classic::mesh::BulkData> bulkData = mesh.getBulkData();
           if(machRank_==0)
           {  
              stk_classic::mesh::Entity * node = bulkData->get_entity(mesh.getNodeRank(),node_id);
              mesh.addEntityToNodeset(*node, nodeset);
           }
        }
      }

    }
    mesh.endModification();
}
Ejemplo n.º 2
0
void SquareQuadMeshFactory::addNodeSets(STK_Interface & mesh) const
{
   mesh.beginModification();

   // get all part vectors
   stk::mesh::Part * lower_left = mesh.getNodeset("lower_left");
   stk::mesh::Part * origin = mesh.getNodeset("origin");

   // std::vector<stk::mesh::Entity*> localElmts;
   // mesh.getMyElements(localElmts);

   Teuchos::RCP<stk::mesh::BulkData> bulkData = mesh.getBulkData();
   if(machRank_==0) 
   {
      // add zero node to lower_left node set
      stk::mesh::Entity * node = bulkData->get_entity(mesh.getNodeRank(),1);
      mesh.addEntityToNodeset(*node,lower_left);

      // add zero node to origin node set
      mesh.addEntityToNodeset(*node,origin);
   }

   mesh.endModification();
}