Storing an variable from UDF at each iteration step

General discussion about Elmer
Post Reply
szlyc0706
Posts: 11
Joined: 04 Jan 2024, 15:33
Antispam: Yes

Storing an variable from UDF at each iteration step

Post by szlyc0706 »

Hi Elmer users,

I am writing a UDF which has input 'xVec' and output 'newXVec', and newXVec is calculated based on current and previous value of xVec in the iteration. So ideally I need somewhere to store an array, and at each node when my UDF is called the array size +1, so the history of newXVec is recoreded.
From post https://www.elmerfem.org/forum/viewtopic.php?t=1383, it is suggesting that I need to store iterative value of newXVec into Variable_t % Values. But I couldn't find any example.
Anyone has any idea about what method I need to use for storing my variable into Variable_t % Values and where I need my store it into?

I appreciate for your help,
Eric
szlyc0706
Posts: 11
Joined: 04 Jan 2024, 15:33
Antispam: Yes

Re: Storing an variable from UDF at each iteration step

Post by szlyc0706 »

I've made some progress!
writing in is using

Code: Select all

call ListAddConsReal(Model%Simulation,'Name',newXVec)
it is working because I can get values out by

Code: Select all

ListGetConstReal( Model % Simulation, 'Name', found)
I am able to write into model%simulation. Is this the right method to be used and the 'Model%Simulation' is the right place to write in? How can I get historical value of it? because this time %PrevValues still returning error.
Post Reply