hexagon logo

Error while Creating pressure using fields. please see error description.

FUNCTION field_pr()
## Variable Declaration
STRING s_name[32]
STRING type[32]
STRING elm_type[32]
INTEGER e_dim
STRING a_kind[32]
STRING elm[256](1)
STRING ap_region[32]
STRING field_name[256](1)
STRING dummy[32]
INTEGER d_const
INTEGER k
INTEGER i_return_value
INTEGER lc_count
lc_count = 10
FOR (k=1 TO lc_count)
 
s_name  = "pr" // str_from_integer(k)
type  = "Pressure"
elm_type = "Element Uniform"
e_dim  = "2D"
a_kind  = "Static"
elm(1)  = "Element xxxxxxxxxxxx"
ap_region = "FEM"
dummy  = ""
d_const  = 1.
field_name(1)= "f:field" // str_from_integer(k)
FOR (k=1 TO 10)
# Create Load case "load_case" and assign it a variable k
i_return_value = loadsbcs_create( s_name, type, elm_type, @
e_dim, a_kind, elm, ap_region, dummy, d_const, field_name )
END FOR
END FUNCTION
​#####################
​PCL Error description:
​########################
​$# (PCL) Mismatched end type. Want: END FOR
​$# File: field_pr.pcl, Line: 46
​$# Line is "end function"
​$# Compilation aborted
  • You have two FOR entries, but only one END FOR. The error message means that Patran's looking for the second END FOR, but only finds END FUNCTION instead.
  • oops! I found that.
    @Darrel Sinclair​ 
    Now one more error is popping up.
    $# (PCL) Mismatched function argument: U_LBC_SF
    ​$# Call traceback...
    ​$#  Function FIELD_PR, Line Number 45
    ​$# Execution aborted
    ​Line 45 is :  i_return_value = loadsbcs_create( s_name, type, elm_type, @ 
    ​​
    ​Rgs,
    ​Vishal
  • "Mismatched function argument" means that a variable is not of the type expected by the function. I think the one it's complaining about is the one called lbc_scale_factor in the documentation. This is supposed to be a real number, but you have no real variables declared.
     
    Your call to loadsbcs_create also only has 10 arguments; the documentation shows it needs 11.
  • @Darrel Sinclair  I have included Real number in my variable declaration. The new error is :
    ​$# Error reported from application LOADS_BCS
    ​$#    "1" is an invalid number of input data fields for the specified Load/BC definition. "3" input data fields are needed.
    ​My code is:
    ​FUNCTION field_pr()
    ## Variable Declaration
    STRING s_name[32]
    STRING type[32]
    STRING elm_type[32]
    STRING e_dim[32]
    STRING a_kind[32]
    STRING elm[256](1)
    STRING ap_region[32]
    STRING field_name[256](1)
    STRING dummy[32]
    REAL d_const
    STRING int_c[32](1)
    INTEGER k
    INTEGER i_return_value
    INTEGER lc_count
    lc_count = 10
    FOR (k=1 TO lc_count)
    loadcase_current_set( "load_case"//str_from_integer(k))
    s_name  = "pr" // str_from_integer(k)
    type  = "Pressure"
    elm_type = "Element Uniform"
    e_dim  = "2D"
    a_kind  = "Static"
    elm(1)  = "Element XXXXX"
    ap_region = "FEM"
    dummy  = ""
    d_const  = 1.
    field_name(1)= "f:field" // str_from_integer(k)
    int_c(1) = ""
    # Create Load case "load_case" and assign it a variable k
    i_return_value = loadsbcs_create( s_name, type, elm_type, @
    e_dim, a_kind, elm, ap_region, dummy, d_const, field_name, int_c )
    END FOR
    END FUNCTION
    ​Rgs,
    ​Vishal
  • A pressure load on 2D elements has three possible entries on the form (top, bottom, and edge pressures), so the PCL function needs an array of three entries. One easy way of checking what you should be using for input is to create the required thing in Patran and look at the command that's issued in the history window. For a pressure load on 2D elements, this is what you get:
     
    loadsbcs_create2( "press", "Pressure", "Element Uniform", "2D", "Static", ["Element 1:25"], "FEM", "", "1.", [" 10", " ", " "], ["", "", ""] )
     
    The last two arguments are string arrays of size 3. Your arrays are size 1.
     
    Most PCL functions also have example code in the documentation that can help with understanding how they're supposed to work.
  • Yes, I have changed the last to array variable declaration. It worked this time. Thank you @Darrel Sinclair​ 
    ​I really want to  owe you a Beer !! :)
    ​Cheers,
    ​Vishal