1+ # #################################################################################
2+
3+ namespace eval ::Mesh {
4+ Kratos::AddNamespace [namespace current]
5+
6+
7+ }
8+ proc Mesh::PrepareMeshGeneration {elementsize} {
9+
10+ GiD_MeshData mesh_criteria to_be_meshed 1 lines [GiD_Geometry list line]
11+ GiD_MeshData mesh_criteria to_be_meshed 1 surfaces [GiD_Geometry list surface]
12+ GiD_MeshData mesh_criteria to_be_meshed 1 volumes [GiD_Geometry list volume ]
13+
14+ # We need to mesh every line and surface assigned to a group that appears in the tree
15+ foreach group [spdAux::GetAppliedGroups] {
16+ GiD_MeshData mesh_criteria to_be_meshed 2 lines [GiD_EntitiesGroups get $group lines]
17+ GiD_MeshData mesh_criteria to_be_meshed 2 surfaces [GiD_EntitiesGroups get $group surfaces]
18+ GiD_MeshData mesh_criteria to_be_meshed 2 volumes [GiD_EntitiesGroups get $group volumes]
19+ }
20+ }
21+
22+
23+ proc Mesh::CheckMeshCriteria { elementsize } {
24+
25+ set force_mesh_order [dict create]
26+ set elements_used [spdAux::GetUsedElements]
27+ set forced_mesh_order -1
28+ foreach element_id $elements_used {
29+ set element [Model::getElement $element_id ]
30+ if {[$element hasAttribute " MeshOrder" ]} {
31+ set element_forces [$element getAttribute " MeshOrder" ]
32+ if {$element_forces eq " Quadratic" } {
33+ set element_forces 1
34+ } else {
35+ set element_forces 0
36+ }
37+ dict set force_mesh_order $element_id $element_forces
38+ if {$forced_mesh_order eq -1} {
39+ set forced_mesh_order $element_forces
40+ } else {
41+ if {$forced_mesh_order ne $element_forces } {
42+ # W "The element $element_id requires a different mesh order"
43+ W " Incompatible mesh orders in elements"
44+ return -1
45+ }
46+ }
47+ }
48+ }
49+
50+ if {$forced_mesh_order ne -1} {
51+
52+ set element [lindex [dict keys $force_mesh_order ] 0]
53+ set previous_mesh_order [write::isquadratic]
54+ set current_mesh_type [Kratos::GetMeshOrderName $previous_mesh_order ]
55+ set desired_mesh_type [Kratos::GetMeshOrderName $forced_mesh_order ]
56+ if {$previous_mesh_order ne $forced_mesh_order } {
57+ W " The element $element requires a different mesh order: $desired_mesh_type "
58+ W " Currently the mesh order is $current_mesh_type . please change it in the menu Mesh > Quadratic type"
59+ return -1
60+ }
61+ }
62+ return 0
63+ }
64+
65+ proc Mesh::AddPointElementsIfNeeded {} {
66+ # Foreach groups assigned in tree
67+ set condition_groups [spdAux::GetUsedConditions]
68+
69+ # condition_groups is a dict of conditionid -> list of group nodes (tdom)
70+ foreach condid [dict keys $condition_groups ] {
71+ set cond [Model::getCondition $condid ]
72+ if {$cond eq " " } {
73+ continue
74+ }
75+
76+ # if group element is point and has topology for points
77+ set topology [$cond getTopologyFeature " Point" 1]
78+ if {$topology eq " " } {
79+ continue
80+ }
81+
82+ set group_nodes [dict get $condition_groups $condid ]
83+ foreach node_tdom $group_nodes {
84+ set group_id [get_domnode_attribute $node_tdom n]
85+
86+ # if group ov is point or condition ov is point
87+ set ov " "
88+ if {[$node_tdom hasAttribute ov]} {
89+ set ov [get_domnode_attribute $node_tdom ov]
90+ } else {
91+ set ov [get_domnode_attribute [$node_tdom parent] ov]
92+ }
93+ if { $ov ne " Point" && $ov ne " point" } {
94+ continue
95+ }
96+
97+ # Get the goodname of the group
98+ set group_id [write::GetWriteGroupName $group_id ]
99+
100+ set node_ids [GiD_EntitiesGroups get $group_id nodes]
101+ set new_nodeids [list ]
102+ foreach nodeid $node_ids {
103+ set new_nodeid [GiD_Mesh create element append Point 1 [list $nodeid ]]
104+ # Add to same groups as the node
105+ lappend new_nodeids $new_nodeid
106+ }
107+ GiD_EntitiesGroups assign $group_id elements $new_nodeids
108+ }
109+ }
110+
111+ }
0 commit comments