PCL Examples > Finite Element Functions > Utilities
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX''">XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX''">   
Utilities
This section contains examples of some of the finite element model utility functions.
 
()
#
#  Purpose          :  This file provides an example of a call to the
#                      function fem_geom_match_closest()
#
#                      This file opens a new database "new.db" and
#                      creates four points. Gets the closest point
#                      for point 4 from the target list of remaining
#                      three points.
#                      
#                      This file can be run by starting a session of
#                      Patran, through the "File","Session",  
#                      "Play" pulldown menus on the menu bar.
#
#  The function fem_geom_match_closest()
#  has the following arguments:
#
#  fem_geom_match_closest
#     (  source_select,
#        target_select,
#        entity_count,
#        match,
#        distance,
#        length )
#
#---------------------------------------------------------------------
#  Variable Declarations
STRING   s_source_select[32]
STRING   s_target_select[32]
INTEGER  i_entity_count
STRING   sv_match[VIRTUAL]
REAL     rv_distance(VIRTUAL)
INTEGER  i_length
INTEGER  i_return_value
STRING   sv_grid_xyz_created_ids[VIRTUAL]
#---------------------------------------------------------------------
#  Open a new database "new.db"
uil_file_new.go("","new.db")
$? YES 36000002
 
#---------------------------------------------------------------------
#  Create four points
 
i_return_value =                                               @
   asm_const_grid_xyz( "1", "[0 0 0][-1 2 0][1 2 0][2 3 0]",   @
      "Coord 0", sv_grid_xyz_created_ids )
dump i_return_value
 
point_label( TRUE )
#---------------------------------------------------------------------
#   Get the closest match of the point 4 from target list
 
s_source_select = "Point 4"
s_target_select = "Point 2 1 3"
 
i_return_value =                                               @
   fem_geom_match_closest                                      @
      (  s_source_select,                                      @
         s_target_select,                                      @
         i_entity_count,                                       @
         sv_match,                                             @
         rv_distance,                                          @
         i_length )
dump i_return_value
dump i_entity_count
dump sv_match
dump rv_distance
dump i_length
 
sys_free_string(sv_grid_xyz_created_ids)
sys_free_string(sv_match)
sys_free_array(rv_distance)
#---------------------------------------------------------------------
   
()
#
#  Purpose          :  This file provides an example of a call to the
#                      function fem_geom_edge_length()
#
#                      This function opens a new database "new.db"
#                      and creates a quadrilateral and a triangular
#                      elements. It then gets the lengths of all the
#                      element edges using this function.
#
#                      This file can be run by starting a session of
#                      Patran, through the "File","Session",  
#                      "Play" pulldown menus on the menu bar.
#
#  The function fem_geom_edge_length()
#  has the following arguments:
#
#  fem_geom_edge_length
#     (  element_select,
#        lengths,
#        entity_count )
#
#---------------------------------------------------------------------
#  Variable Declarations
STRING   s_element_select[64]
REAL     rv_lengths(VIRTUAL)
INTEGER  i_entity_count
INTEGER  i_return_value
STRING   sv_elems_created[VIRTUAL]
 
#---------------------------------------------------------------------
#  Open a new database "new.db"
uil_file_new.go("","new.db")
$? YES 36000002
 
#---------------------------------------------------------------------
#  Create a quadrilateral element
 
i_return_value =                                              @
   fem_create_elems ("Quad", "Quad4", "1", "Standard",        @
                     TRUE, "[0 0 0] ","[1 0 0] ",             @
                     "[1 1 0] ", "[0 1 0] ", "", "", "",      @
                     "", sv_elems_created )
dump i_return_value
 
quad_elem_label( TRUE )
 
#---------------------------------------------------------------------
#   Create a triangular element
 
i_return_value =                                              @
   fem_create_elems( "Tri ", "Tria3", "2", "Standard",        @
                     TRUE, "[2 0 0] ", "[3 0 0] ",            @
                     "[2 1 0] ", "", "", "", "", "",          @
                     sv_elems_created )
dump i_return_value
tri_elem_label( TRUE )
 
#---------------------------------------------------------------------
#   Get lengths of all the edges
s_element_select = "Elm 1.1.1 1.1.2 1.1.3 1.1.4 2.1.1 2.1.2 2.1.3"
 
i_return_value =                                              @
   fem_geom_edge_length                                       @
      (  s_element_select,                                    @
         rv_lengths,                                          @
         i_entity_count )
dump i_return_value
dump rv_lengths
dump i_entity_count
 
sys_free_string(sv_elems_created)
sys_free_array(rv_lengths)
#---------------------------------------------------------------------
()
#
#  Purpose          :  This file provides an example of a call to the
#                      function fem_geom_edge_length2()
#
#                      This file opens a new database "new.db",
#                      creates a cube and meshes it. Using this
#                      function it gets the edge length of two
#                      elements by specifying the required face and
#                      edge ids.
#
#                      This file can be run by starting a session of
#                      Patran, through the "File","Session",  
#                      "Play" pulldown menus on the menu bar.
#
#  The function fem_geom_edge_length2()
#  has the following arguments:
#
#  fem_geom_edge_length2
#     (  edge_count,
#        element_id,
#        element_face_id,
#        element_face_edge_id,
#        segment_count,
#        edge_length )
#
#---------------------------------------------------------------------
#  Variable Declarations
INTEGER  i_edge_count
INTEGER  ia_element_id(2)
INTEGER  ia_element_face_id(2)
INTEGER  ia_element_face_edge_id(2)
INTEGER  i_segment_count
REAL     rv_edge_length(VIRTUAL)
INTEGER  i_return_value
STRING   sv_hpat_xyz_created_ids[VIRTUAL]
INTEGER  i_mesh_solid_num_nodes
INTEGER  i_mesh_solid_num_elems
STRING   sv_mesh_s_nodes_created[VIRTUAL]
STRING   sv_mesh_s_elems_created[VIRTUAL]
 
#---------------------------------------------------------------------
#  Open a new database "new.db"
uil_file_new.go("","new.db")
$? YES 36000002
 
#---------------------------------------------------------------------
#  Create a solid
 
i_return_value =                                                @
   asm_const_hpat_xyz( "1", "<1 1 1>", "[0 0 0]", "Coord 0",    @
                        sv_hpat_xyz_created_ids )
dump i_return_value
 
i_return_value =                                                @
   ga_view_aa_set (23., -34., 0.)
dump i_return_value
 
#---------------------------------------------------------------------
#  Mesh the solid
 
i_return_value =                                                @
   fem_create_mesh_sol_3( "IsoMesh", 0, "Solid 1 ", 1, [0.5],   @
                           "Hex8", "1", "1", "Coord 0",         @
                           "Coord 0", i_mesh_solid_num_nodes,   @
                           i_mesh_solid_num_elems,              @
                           sv_mesh_s_nodes_created,             @
                           sv_mesh_s_elems_created )
dump i_return_value
 
#---------------------------------------------------------------------
#  Get the edge lengths of elements
 
i_edge_count               = 2
ia_element_id(1)           = 1
ia_element_id(2)           = 2
ia_element_face_id(1)      = 5
ia_element_face_id(2)      = 0
ia_element_face_edge_id(1) = 2
ia_element_face_edge_id(2) = 8
i_segment_count = 2
 
i_return_value =                                                @
   fem_geom_edge_length2                                        @
      (  i_edge_count,                                          @
         ia_element_id,                                         @
         ia_element_face_id,                                    @
         ia_element_face_edge_id,                               @
         i_segment_count,                                       @
         rv_edge_length )
dump i_return_value
dump rv_edge_length
 
sys_free_string(sv_hpat_xyz_created_ids)
sys_free_string(sv_mesh_s_nodes_created)
sys_free_string(sv_mesh_s_elems_created)
sys_free_array(rv_edge_length)
#---------------------------------------------------------------------
   
()
#
#  Purpose          :  This file provides an example of a call to the
#                      function fem_geom_face_area()
#
#                      This file opens a new database "new.db",
#                      creates a quadrilateral and a triangular
#                      elements. Using this function it gets the
#                      face area of these two elements.
#
#                      This file can be run by starting a session of
#                      Patran, through the "File","Session",  
#                      "Play" pulldown menus on the menu bar.
#
#  The function fem_geom_face_area()
#  has the following arguments:
#
#  fem_geom_face_area
#     (  element_select,
#        areas,
#        entity_count )
#
#---------------------------------------------------------------------
#  Variable Declarations
STRING   s_element_select[32]
REAL     rv_areas(VIRTUAL)
INTEGER  i_entity_count
INTEGER  i_return_value
STRING   sv_elems_created[VIRTUAL]
 
#---------------------------------------------------------------------
#  Open a new database "new.db"
uil_file_new.go("","new.db")
$? YES 36000002
 
#---------------------------------------------------------------------
#  Create a quadrilateral element
 
i_return_value = fem_create_elems( "Quad", "Quad4", "1",        @
   "Standard", TRUE, "[0 0 0] ","[1 0 0] ", "[1 1 0] ",         @
   "[0 1 0] ", "", "", "", "",   sv_elems_created )
dump i_return_value
 
quad_elem_label( TRUE )
 
#---------------------------------------------------------------------
#  Create a triangular element
 
i_return_value = fem_create_elems( "Tri ", "Tria3", "2",        @
   "Standard", TRUE, "[2 0 0] ", "[3 0 0] ", "[2 1 0] ", "", "",@
   "", "", "", sv_elems_created )
dump i_return_value
 
tri_elem_label( TRUE )
 
#---------------------------------------------------------------------
#  Get the face areas of the elements
 
s_element_select = "Elem 1 2 "
i_return_value =                                                @
   fem_geom_face_area                                           @
      (  s_element_select,                                      @
         rv_areas,                                              @
         i_entity_count )
dump i_return_value
dump rv_areas
dump i_entity_count
 
sys_free_string(sv_elems_created)
sys_free_array(rv_areas)
#---------------------------------------------------------------------
()
#
#  Purpose          :  This file provides an example of a call to the
#                      function fem_geom_elem_volume()
#
#                      This file opens a new database "new.db", and 
#                      creates brick and wedge elements and gets
#                      their volumes using this function.
#
#                      This file can be run by starting a session of
#                      Patran, through the "File","Session",  
#                      "Play" pulldown menus on the menu bar.
#
#  The function fem_geom_elem_volume()
#  has the following arguments:
#
#  fem_geom_elem_volume
#     (  element_select,
#        volumes,
#        entity_count )
#
#---------------------------------------------------------------------
#  Variable Declarations
STRING   s_element_select[32]
REAL     rv_volumes(VIRTUAL)
INTEGER  i_entity_count
INTEGER  i_return_value
STRING   sv_hpat_xyz_created_ids[VIRTUAL]
INTEGER  i_mesh_solid_num_nodes
INTEGER  i_mesh_solid_num_elems
STRING   sv_s_nodes_created[VIRTUAL]
STRING   sv_s_elems_created[VIRTUAL]
#---------------------------------------------------------------------
#  Open a new database "new.db"
uil_file_new.go("","new.db")
$? YES 36000002
 
#---------------------------------------------------------------------
#  Create two solids
 
i_return_value =                                                @
   asm_const_hpat_xyz( "1", "<1 1 1>", "[0 0 0]", "Coord 0",    @
                        sv_hpat_xyz_created_ids )
dump i_return_value
 
i_return_value =                                                @
   asm_const_hpat_xyz( "", "<1 1 1>", "[2 0 0]", "Coord 0",     @
                        sv_hpat_xyz_created_ids )
dump i_return_value
 
i_return_value =                                                @
   ga_view_aa_set (23., -34., 0.)
dump i_return_value
 
#---------------------------------------------------------------------
#  Mesh the solid 1 with brick element
 
i_return_value =                                                @
   fem_create_mesh_sol_3( "IsoMesh", 0, "Solid 1 ", 1, [1.],    @
                           "Hex8", "1", "1", "Coord 0",         @
                           "Coord 0", i_mesh_solid_num_nodes,   @
                           i_mesh_solid_num_elems,              @
                           sv_s_nodes_created, sv_s_elems_created )
dump i_return_value
 
hex_elem_label( TRUE )
 
#---------------------------------------------------------------------
#  Mesh the solid 2 with wedge element
 
i_return_value =                                               @
   fem_create_mesh_sol_3( "IsoMesh", 0, "Solid 2 ", 1,         @
                           [1.], "Wedge6", "9", "2", "Coord 0",@
                           "Coord 0", i_mesh_solid_num_nodes,  @
                           i_mesh_solid_num_elems,             @
                           sv_s_nodes_created,  sv_s_elems_created )
dump i_return_value
 
wedge_elem_label( TRUE )
 
#---------------------------------------------------------------------
#  Get the volume of brick and wedge elements
 
s_element_select = "Elem 1:3 "
i_return_value =                                               @
   fem_geom_elem_volume                                        @
      (  s_element_select,                                     @
         rv_volumes,                                           @
         i_entity_count )
dump i_return_value
dump rv_volumes
dump i_entity_count
 
sys_free_string(sv_hpat_xyz_created_ids)
sys_free_string(sv_s_nodes_created)
sys_free_string(sv_s_elems_created)
sys_free_array(rv_volumes)
#---------------------------------------------------------------------
   
()
#
#  Purpose          :  This file provides an example of a call to the
#                      function fem_geom_elem_location()
#
#                      This file opens a new database "new.db",
#                      creates a quadrilateral element and gets the
#                      location of all the element edges.
#
#                      This file can be run by starting a session of
#                      Patran, through the "File","Session",  
#                      "Play" pulldown menus on the menu bar.
#
#  The function fem_geom_elem_location()
#  has the following arguments:
#
#  fem_geom_elem_location
#     (  element_select,
#        locations,
#        entity_count )
#
#---------------------------------------------------------------------
#  Variable Declarations
STRING   s_element_select[64]
REAL     rv_locations(VIRTUAL)
INTEGER  i_entity_count
INTEGER  i_return_value
STRING   sv_elems_created[VIRTUAL]
 
#---------------------------------------------------------------------
#  Open a new database "new.db"
uil_file_new.go("","new.db")
$? YES 36000002
 
#---------------------------------------------------------------------
#  Create a quadrilateral element
 
i_return_value =                                              @
   fem_create_elems( "Quad", "Quad4", "1", "Standard",        @
                     TRUE, "[0 0 0] ","[1 0 0] ",            @
                     "[1 1 0] ", "[0 1 0] ", "", "", "",     @
                     "",   sv_elems_created )
dump i_return_value
 
quad_elem_label( TRUE )
 
#---------------------------------------------------------------------
#  Get the element edge locations
 
s_element_select = "Elm 1 Elm 1.1.1 Elm 1.1.2 Elm 1.1.3 Elm 1.1.4"
 
i_return_value =                                             @
   fem_geom_elem_location                                    @
      (  s_element_select,                                   @
         rv_locations,                                       @
         i_entity_count )
dump i_return_value
dump rv_locations
dump i_entity_count
 
sys_free_string(sv_elems_created)
sys_free_array(rv_locations)
#---------------------------------------------------------------------
   
()
#
#  Purpose          :  This file provides an example of a call to the
#                      function fem_get_mesh_edge_def_data()
#
#                      This file opens a new database "new.db"
#                      creates a surface and creates mesh seed for
#                      all the edges with different methods. It
#                      meshes the surface and gets the mesh and
#                      mesh seed details for all the edges using
#                      this function.
#
#                      This file can be run by starting a session of
#                      Patran, through the "File","Session",  
#                      "Play" pulldown menus on the menu bar.
#
#  The function fem_get_mesh_edge_def_data()
#  has the following arguments:
#
#  fem_get_mesh_edge_def_data
#     (  curve_id,
#        mesh_status,
#        mesh_type,
#        num_elements,
#        mesh_ratio,
#        num_hard,
#        node_locations )
#
#---------------------------------------------------------------------
#  Variable Declarations
INTEGER  i_curve_id
INTEGER  i_mesh_status
INTEGER  i_mesh_type
INTEGER  i_num_elements
REAL     r_mesh_ratio
INTEGER  i_num_hard
REAL     rv_node_locations(VIRTUAL)
INTEGER  i_return_value
STRING   sv_patch_xy_created_ids[VIRTUAL]
INTEGER  i_mesh_surfa_num_nodes
INTEGER  i_mesh_surfa_num_elems
STRING   sv_mesh_s_nodes_created[VIRTUAL]
STRING   sv_s_elems_created[VIRTUAL]
INTEGER  i_count
INTEGER  ia_curve_ids(4) = [1, 2, 3, 4]
#---------------------------------------------------------------------
#  Open a new database "new.db"
uil_file_new.go("","new.db")
$? YES 36000002
 
#---------------------------------------------------------------------
#  Create a surface
 
i_return_value =                                                 @
   asm_const_patch_xyz( "1", "<1 1 0>", "[0 0 0]", "Coord 0",    @
                           sv_patch_xy_created_ids )
dump i_return_value
 
#---------------------------------------------------------------------
#  Create mesh seed for all the surface edges
 
i_return_value =                                                 @
   mesh_seed_create( "Surface 1.1 ", 1, 5, 0., 0., 0. )
dump i_return_value
 
i_return_value =                                                 @
   mesh_seed_create( "Surface 1.2 ", 3, 5, 1.25, 0., 0. )
dump i_return_value
 
i_return_value =                                                 @
   mesh_seed_create( "Surface 1.3 ", 5, 5, 1.5, 0., 0. )
dump i_return_value
 
i_return_value =                                                 @
   mesh_seed_create_tabular( "Surface 1.4 ", "Arc_Length",       @
                           6, [0., 0.2, 0.4, 0.6, 0.8, 1., 0., 0.] )
dump i_return_value
 
#---------------------------------------------------------------------
#  Mesh the surface
 
i_return_value =                                                 @
   fem_create_mesh_surf_2( "IsoMesh", 0, "Surface 1 ",           @
                           1, [0.1], "Quad4", "1",  "1",         @
                           "Coord 0", "Coord 0",                 @
                           i_mesh_surfa_num_nodes,               @ 
                           i_mesh_surfa_num_elems,               @
                           sv_mesh_s_nodes_created,              @
                           sv_s_elems_created )
dump i_return_value
 
#---------------------------------------------------------------------
#  Get the mesh and mesh seed details of all the suface edges
 
FOR (i_count = 1 TO 4 )
   i_curve_id = ia_curve_ids(i_count) 
 
   i_return_value =                                              @
      fem_get_mesh_edge_def_data                                 @
         (  i_curve_id,                                          @
            i_mesh_status,                                       @
            i_mesh_type,                                         @
            i_num_elements,                                      @
            r_mesh_ratio,                                        @
            i_num_hard,                                          @
            rv_node_locations )
   dump i_return_value
   dump i_mesh_status
   dump i_mesh_type
   dump i_num_elements
   dump r_mesh_ratio
   dump i_num_hard
   dump rv_node_locations
 
END FOR
 
sys_free_array(rv_node_locations)
sys_free_string(sv_patch_xy_created_ids)
sys_free_string(sv_mesh_s_nodes_created)
sys_free_string(sv_s_elems_created)
#---------------------------------------------------------------------