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
Storing an variable from UDF at each iteration step
Re: Storing an variable from UDF at each iteration step
I've made some progress!
writing in is using
it is working because I can get values out by
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.
writing in is using
Code: Select all
call ListAddConsReal(Model%Simulation,'Name',newXVec)
Code: Select all
ListGetConstReal( Model % Simulation, 'Name', found)
-
- Site Admin
- Posts: 4841
- Joined: 22 Aug 2009, 11:57
- Antispam: Yes
- Location: Espoo, Finland
- Contact:
Re: Storing an variable from UDF at each iteration step
Hi Eric,
What is the size of your variable?
Are you sure that your case is an UDF rather than a Solver. If you have transient history then the Solver provides some services to advance a variable forward when doing timestepping. So what would the UDF do? The answer depends on your goal.
-Peter
What is the size of your variable?
Are you sure that your case is an UDF rather than a Solver. If you have transient history then the Solver provides some services to advance a variable forward when doing timestepping. So what would the UDF do? The answer depends on your goal.
-Peter