Setting Condition

Moderator: GiD Team

Post Reply
waseda
Posts: 13
Joined: Thu Dec 24, 2015 4:31 am
Location: Japan
Contact:

Setting Condition

Post by waseda »

This is a question for clarification about the keyword, ovm.

I'm trying to set displacement boundary conditions (fixed or unfixed) in my problemtype.

[spd file]
<!-- displacement boundary conditions -->
<condition n="Disp_Bc" pn="Displacement boundary conditions" ov="surface" ovm="" icon="icon1" groups_icon="group1" help="iffix value should be 1 or 0">
<value n="Iffix_x" pn="Fix x-displacement" v="0" help="Specify the fixed boundary conditions you want to apply"/>
<symbol proc="pic1.png" orientation="global"/>
</condition>

[tcl file]
set list1 [list "Disp_Bc"]
set condition_formats [list {"%1d" "node" "id"} {"%13.5e" "property" "Iffix_x"}]
set number_of_conditions [customlib::GetNumberOfNodes $list1]
customlib::WriteString "Displacement Boundary Conditions"
customlib::WriteString $number_of_conditions
customlib::WriteString "Iffix ifix_x ifix_y ifix_z"
customlib::WriteNodes $list1 $condition_formats "" active

It works just fine in GiD. But what is the meaning of ov=""? When I change the above script to ovm="node", the tcl command didn't work. (Return 0 for $number_of_conditions.) I hope you can give me some clarificaiton about the ovm setting here.

Regards,

Kenji Furui
User avatar
escolano
Posts: 1922
Joined: Sun Sep 05, 1982 10:51 pm

Re: Setting Condition

Post by escolano »

in your case you have ov="surface" to declare that this condition must be applied in geometry to surface entities
and ovm declare what to do when generating a mesh, which entities will inherit this condition (or which entities will be allowed to manually assign them to a group of this condition, but manual assignment of conditions over mesh is unrecommended)

ovm could be a list of element, node, face_element or ""
https://gidsimulation.atlassian.net/wik ... /condition

I think that in your case (by your tcl writing code) really do you want that only the nodes are marked with this condition, then in my opinion must be set
ovm="node"
otherwise with ovm="" will be marked with this condition not only the nodes but also the triangle elements of the surface (or the faces of the tetrahedra of the volume in case that the surface is boundary of a volume)

the procedure
customlib::GetNumberOfNodes
  • must return the number of nodes with the condition named Disp_Bc (that are the nodes of the groups with name referenced by these conditions Disp_Bc in the data tree)
    but it seems that if the group contain only nodes and any element it returns 0 !!
    this is a mistake (or a limitation of the current implementation of this proc that is not so general as expected) !

    and is similar for customlib::WriteNodes

    I have fixed it for next version 16.0.7 and 16.1.7d

    to fix your current version can replace these procs in >GiD>/scripts/customlib_extras/customlib_extras.tcl

    Code: Select all

    proc customlib::GetElementsFormats {condition_n parameters {unit_mode "default"}} {
        set mat_dict ""
        set formats [dict create]
        set rootNode [customlib::GetBaseRoot]
        set xp [format_xpath {//condition[@n=%s]} $condition_n]
        foreach condNode [$rootNode selectNodes $xp] {
            foreach gNode [$condNode selectNodes {.//group}] {
                set group [$gNode @n]
                set ov ""
                catch {set ov [$gNode @ov]}
                if {$ov eq ""} {
                    set ov [[$gNode parent] @ov]
                }
               set ovm [[$gNode parent] @ovm]
                if { $ovm == "node" } {
                    #there are not expected elements
                    set nnodes 0
                    set etype ""
                } else {
                    lassign [customlib::GetElementTypeAndAmountNodes $group $ov] etype nnodes
                }
                if {$nnodes ne ""} {
                    set my_mat ""
                    set valueNode [$gNode selectNodes {.//value[@n="material"]}]
                    if {$valueNode ne ""} {
                        if {$mat_dict eq ""} {
                            set mat_dict [customlib::GetMaterials used]
                        }
                        set material_name [get_domnode_attribute $valueNode v]
                        if {![dict exists $mat_dict $material_name MID]} {
                            error [_ "It's mandatory to call customlib::InitMaterials with the used conditions"]
                        } else {
                            set my_mat [dict get $mat_dict $material_name]
                        }
                    }
                    set val [customlib::GetFormatDict $gNode $my_mat $parameters $unit_mode]
                    dict set formats $group "$val\n"
                }
            }
        }
        return $formats
    }
    
    
    proc customlib::GetFormatDict {gNode material parameters {unit_mode "default"}} {
        set f ""
        set unit_conversion_system convert_value_to_default
        if {$unit_mode ne "default"} {set unit_conversion_system convert_value_to_active}
        if {$gNode ne ""} {
            set group [$gNode @n]
            set ov ""
            catch {set ov [$gNode @ov]}
            if {$ov eq ""} {
                set ov [[$gNode parent] @ov]
            }
            set ovm [[$gNode parent] @ovm]
            if { $ovm == "node" } {
                #there are not expected elements
                set nnodes 0
                set etype ""
            } else {                       
                lassign [customlib::GetElementTypeAndAmountNodes $group $ov] etype nnodes
            }
        }
        foreach item $parameters {
            lassign $item fmt what attr
            switch $what {
                "element" {
                    if {$attr eq "id"} {append f "$fmt "}
                    if {$attr eq "connectivities"} {append f "[string repeat "$fmt " $nnodes]"}
                }
                "node" {
                    if {$attr eq "id"} {append f "$fmt "}
                }
                "material" {
                    set attr [dict get $material $attr]
                    append f "[format $fmt $attr]"
                }
                "property" {
                    set xp2 {.//value[@n=$attr]}
                    set valueNode [$gNode selectNodes $xp2]
                    if {$unit_mode ne "none"} {
                        set value [gid_groups_conds::$unit_conversion_system $valueNode]
                    } else {
                        set value [get_domnode_attribute $valueNode v]
                    }
                        append f "[format $fmt $value]"
                    }
                    "string" {
                        append f "[format $fmt $attr]"
                    }
                    default {
                        error [_ "Error defining parameters for %s - %s - %s" $group $attr $what]
                    }
                }
            }
        return $f
    }
waseda
Posts: 13
Joined: Thu Dec 24, 2015 4:31 am
Location: Japan
Contact:

Re: Setting Condition

Post by waseda »

Escolano,

Than you so much for your answering my question. I really appreicate it.

Kenji
Post Reply