Slow runtime when assigning struct reference

Fair warning to anyone reading this: Mechanical engineer here, leave your sensibilities at the door.

I’m playing around with building a finite volume code in Julia and am having trouble when trying to assign references to my mesh (a larger struct containing cell/face data) inside another struct designed to hold values for the cells/faces

Basically what I have is the following:

mutable struct mesh_format
id::Int64
nodes::Vector{node_format}
faces::Vector{face_format}
cells::Vector{cell_format}
end

mutable struct mesh_var
#reference to the mesh
mesh::mesh_format
arrays for the faces, cells
cellVals::Vector{Float64}
faceVals::Vector{Float64}
end

mesh_format holds the geometry of the mesh and mesh_var holds the actual values and reference to the mesh for operations that need to know geometric data.

My first test case isn’t super obscene, 4800 cells and 9760 faces. The issue arises when I try to assign reference to mesh_var.mesh in a constructor or elsewhere in my code. When I do so the execution seems to stall, or at least take a very long time to run. If I make the assignment in the console it occurs within seconds, which I expect as this should just be a pointer to the mesh. Am I missing something here?

Without an example that could be run, it is hard to say much.

1 Like

Fixed this (just after I posed it, isn’t that always the case)

Solution was to add a simple operation as the last line of the script i was trying to run, rather than leave it being assignment to a mesh_var or something of the like.

I THINK its because of this:
I think Juno (which I was using) suppresses output from running a script but doesn’t really? Looks like Julia was trying to output my last variable, which included reference to the mesh and also included circular references so it was taking forever to ‘output’ but not actually outputting (Juno still suppresses this somewhere along the way I guess though since nothing ends up on the console out?)

please quote your code and provide a self-contained MWE