how to query node ID through its coordinates

Post Reply
VHrb
Posts: 3
Joined: Fri Mar 07, 2025 11:41 am

how to query node ID through its coordinates

Post by VHrb » Fri Mar 07, 2025 12:42 pm

Dear STKO team,

I am running modal analysis of a model to which I gradually introduce geometrical alterations to analyze their influence on the frequencies and mode shapes. I have created a selection set with the nodes that I use to record the eigen vectors, and by using the Labels visualization tool I find the node IDs manually. However, with every alteration in the geometry, the mesh changes and so does the IDs of the nodes and I have to repeat the process for each model.
Is there any script that I could use to query the node ID based on their coordinates?

STKO Team
Posts: 3066
Joined: Tue Oct 29, 2019 8:45 am

Re: how to query node ID through its coordinates

Post by STKO Team » Fri Apr 11, 2025 7:58 am

There are many ways to do it, depending on the scenario.
Can you better describe in detail what you want to do?
Is it something you need in STKO pre processor? STKO post processor? in OpenSees for some custom operation?

VHrb
Posts: 3
Joined: Fri Mar 07, 2025 11:41 am

Re: how to query node ID through its coordinates

Post by VHrb » Thu Jun 05, 2025 12:51 pm

Dear STKO team,

Thank you for your reply.

I need it in pre-processor.

I have a micromodel of an arch like this:
1.jpg
1.jpg (171.92 KiB) Viewed 3094 times
and I have a set of nodes where I want to record the eigen vectors:
2.jpg
2.jpg (65.49 KiB) Viewed 3094 times
through this script:

Code: Select all

proc modal { num_modes filename1 {eig_solver -genBandArpack}} {

	# begin
	puts "\nRunning modal analysis ..."

	# get all node tags
	set nodes [getNodeTags]
	if {[llength $nodes] == 0} {
		error "modal - Error: no node in model"
	}

	# check problem size (2D or 3D) from the first node, we do not support mixed dimesions!!
	set ndm [llength [nodeCoord [lindex $nodes 0]]]

	# compute total masses
	if {$ndm == 3} { 
		set ndf_max 6 
		set total_mass {0.0 0.0 0.0 0.0 0.0 0.0}
		set mass_labels {"MX" "MY" "MZ" "MRX" "MRY" "MRZ"}
		set mass_labels1 {"MODE" "MX" "MY" "MZ" "MRX" "MRY" "MRZ"}
	} else {
		set ndf_max 3
		set total_mass {0.0 0.0 0.0}
		set mass_labels {"MX" "MY" "MRZ"}
		set mass_labels1 {"MODE" "MX" "MY" "MRZ"}
	}
	foreach node $nodes {
		set indf [llength [nodeDisp $node]]
		for {set i 0} {$i < $indf} {incr i} {
			set imass [nodeMass $node [expr $i+1]]
			set imass_total [lindex $total_mass $i]
			lset total_mass $i [expr $imass_total + $imass]
		}
	}

	# some constants
	set pi [expr acos(-1.0)]
	
	#modalDamping 0.02 0.02
	
	# solve the eigenvalue problem
	set lambdas [eigen $eig_solver $num_modes]
	if {[llength $lambdas] != $num_modes} {
		error "modal - Error: something went wrong in the eigen analysis"
	}

	#open a new document to record the values of the eigenvectors
	set fp1 [open $filename1 w]

	#set nodes_x {8} where we are interested in recording the eigenvectors TO BE EDITED!!!!
	set nodes_x {1070 831 1024 864 793 920 422 915 874 928 805 721 446 440 1185 506 29 392 458 761 1091 548 1142 1038 432 1035 536 216 1148 747 166 174 851 187 801 862 715 560}

	# process each mode of vibration
	for {set imode 0} {$imode < $num_modes} {incr imode} {

		# compute i-mode eigen analysis derived data
		set lambda [lindex $lambdas $imode]
		set omega [expr {sqrt($lambda)}]
		set omega [expr {sqrt($lambda)}]
		set frequency [expr $omega / 2.0 / $pi]
		set period [expr 1.0 / $frequency]

		foreach node $nodes_x {
			# get eigenvector
			puts $node
			set V [nodeEigenvector $node [expr $imode+1]]
			puts $fp1 "$node  $V"
		}

	}
	# done
	close $fp1
	puts "\nModal Analysis done\n"
}

#ask for the number of modes you want to extract TO BE EDITED!
modal 6 "_eigenvectors.txt" "_frequencies.txt"
record
Then I gradually remove some joints to simulate a crack opening:
3.jpg
3.jpg (167.13 KiB) Viewed 3094 times
and I want to run the modal analysis again and compare the results recorded over the same nodes with the original model. However, with every removed joint, I have to remesh, so the numbering of the nodes changes, and I have to repeat the process of finding the Node IDs for each model.
4.jpg
4.jpg (66.48 KiB) Viewed 3092 times
So my question was if there is a smarter way to do it, for example, to query the Node ID based on the x,y,z coordinates of the nodes, as those don't change.

Thank you again,
Viktoria

STKO Team
Posts: 3066
Joined: Tue Oct 29, 2019 8:45 am

Re: how to query node ID through its coordinates

Post by STKO Team » Thu Jun 05, 2025 4:24 pm

The easiest way is to:
  • create a selection set with the nodes you want
  • create a region analysisStep, and in the region you can tell STKO to generate a tcl list, give it a name
  • In your tcl script you can now reference that list

VHrb
Posts: 3
Joined: Fri Mar 07, 2025 11:41 am

Re: how to query node ID through its coordinates

Post by VHrb » Mon Jun 09, 2025 6:48 am

It works, thank you very much for your help

STKO Team
Posts: 3066
Joined: Tue Oct 29, 2019 8:45 am

Re: how to query node ID through its coordinates

Post by STKO Team » Mon Jun 09, 2025 7:54 am

You're welcome

Post Reply