This post address the issue that after running fenicsx for several times, the cache file takes too much disk storage. Sometimes the program interrupted with error prompting clear cache. Below is my solution in the user end.
You can find and clear the hidden file .cache. You can confirm if this files takes huge space before deleting.
For Mac user, go to the disk you install fenicsx, go to Users/your_user_name/, and press cmd+shift+. to show hidden files, delete .cache.
For Ubuntu, go to Home, press Ctrl+H to show hidden files, delete .cache.
Note that FEniCSx should not generate a lot of files in cache.
This might point to a systematic issue in your code where your form should be independent of some parameters, but you are compiling a file for each option (say a constant value that is changing, but not wrapped as dolfinx.fem.Constant
. See for instance: Form compilation — FEniCS Tutorial @ Sorbonne which contains various ways of minimizing the amount of generated code.
Should I define all numbers in my code using dolfinx.fem.Constant
or just for the changed ones or doesn’t matter?
For any number that might change within a loop, causing you to have to re-call dolfinx.fem.form
you should define them as constants outside the loop. If you have parameters that will never change, say like a 0.5 or so, you don’t need to wrap it (but it doesn’t hurt to wrap it)
I see thank you very much!
By the way do I need to clear cache some time even I define constant variable as you indicated if I have to solve the nonlinear systems tens of thousands of times or even more?
No, if you define your form outside the loops, and ensure that it is generalized for the various runs and iterations, there will only be code generation once.
I see thank you very much!