Fish operator, hist command, local and global variables

Hi everybody!

This question may be trivial, so sorry in advance. I have, let’s say, 200 cross sections throughout the complicated structure. Sections are used to integrate and plot various outputs. I use fish operator and splitting for efficient summation, and plan to use callback. But, how can I efficiently reach local sum from the operator and use it globally with fish hist (or some other strategy) to plot it? I suppose the problem lies in the connection between local variables in operator and global variables that should be defined for plotting purposes. But how to do that efficiently for many cross sections?

Thanks!

Parts of the code are:

fish operator reactions(gx)
;
local reactions_total = vector(0,0,0)
local reactions_tower = vector(0,0,0)
local reactions_nave = vector(0,0,0)
local reactions_buttress = vector(0,0,0)
;
if block.gp.pos.z(gx) < 0.01 then
local reac = block.gp.force.reaction(gx)
reactions_total += reac
if block.gp.pos.x(gx) <= 10.8 & block.gp.pos.z(gx) <= 0.01 then
reactions_tower += reac
endif
if block.gp.pos.x(gx) > 10.8 & block.gp.pos.z(gx) <= 0.01 then
reactions_nave += reac
endif
if block.gp.pos.x(gx) >= 21.04 & block.gp.pos.x(gx) <= 27.85 & block.gp.pos.y(gx) >= -0.01 & block.gp.pos.y(gx) <= 4.965 & block.gp.pos.z(gx) <= 0.01 then
reactions_buttress += reac
endif
endif
end

….

; I’m dead lost here.

fish hist name … ; I need to plot histories of reactions_total or reactions_tower or reactions_nave or reactions_buttress

model solve time 16.35 fish-call -100 [reactions(::block.gp.list)] interval 1000

program return

fish callback add [reactions(::block.gp.list)] -100 interval 1000

The short answer is that you can’t use locals for this. Presumably you want to sum gridpoint forces over multiple gridpoints? In this case they will need to be globals, in which case you can’t sum inside an operator (without locking).

I would make a regular FISH function (not an operator) that does all the work. Since you are only calling it every 1000 steps, it sholdn’t slow things down too much. You will need to make a separate FISH variable for each thing you want to record as a history. Then you don’t need to use a fish callback. Just take a history of the function.

I expect you don’t want to define 200 different FISH variables. Another way to do it would be to store data in tables. Then you can plot them just like histories. In this case you would need to use a fishcall.

Thanks Jim!

Regards!

Damir