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+ set topology [$cond getTopologyFeature " Point" 1]
76+ if {$topology eq " " } {
77+ continue
78+ }
79+ W " Groups assigned to condition $condid will be meshed with Point elements."
80+
81+ set group_nodes [dict get $condition_groups $condid ]
82+ foreach node_tdom $group_nodes {
83+ set group_id [get_domnode_attribute $node_tdom n]
84+ # Get the goodname of the group
85+ set group_id [write::GetWriteGroupName $group_id ]
86+
87+ set node_ids [GiD_EntitiesGroups get $group_id nodes]
88+ set new_nodeids [list ]
89+ foreach nodeid $node_ids {
90+ set new_nodeid [GiD_Mesh create element append Point 1 [list $nodeid ]]
91+ # Add to same groups as the node
92+ lappend new_nodeids $new_nodeid
93+ }
94+ GiD_EntitiesGroups assign $group_id elements $new_nodeids
95+ }
96+ }
97+
98+ # if group element is point and has topology for points
99+
100+ # foreach nodeid [GiD_Mesh] GiD_Mesh create element append Point 1 [list $nodeid]
101+ }
0 commit comments