nonlocal external functions

Please login with a confirmed email address before reporting spam

Hi,

Depending on the grid size the custom function (matlab or external dll) may be called several times per evaluation step for different grid cell blocks (assembly block sizes). However, my function operations are non-local, i.e. the function must use (global) values outside the grid cells that is sent to the function, is there a way to get around this?

Thank you very much!


2 Replies Last Post 10 déc. 2024, 20:15 UTC−5
Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 5 days ago 10 déc. 2024, 03:02 UTC−5

There is no general way to get the MATLAB function calls (or external functions) to work on a global scale. You can increase the block size and see if that works for your model, but even then there is a limit to how large blocks can be.

You can see if you can generate a global operator (e.g. an integral, max/min or something similar) that uses your custom functions as inputs.

Alternatively, you can solve the model. Use the COMSOL API do extract the data and calculate the quantities you need. You can then feed the calculated data into your model and solve the model again if that is required.

-------------------
Lars Gregersen
Comsol Denmark
There is no general way to get the MATLAB function calls (or external functions) to work on a global scale. You can increase the block size and see if that works for your model, but even then there is a limit to how large blocks can be. You can see if you can generate a global operator (e.g. an integral, max/min or something similar) that uses your custom functions as inputs. Alternatively, you can solve the model. Use the COMSOL API do extract the data and calculate the quantities you need. You can then feed the calculated data into your model and solve the model again if that is required.

Please login with a confirmed email address before reporting spam

Posted: 4 days ago 10 déc. 2024, 20:15 UTC−5

Hi Lars,

Many thanks for your reply~ Could you let me how to increase the block size? And, I am wondering why the interface is designed to only send data in blocks? Thanks!

Hi Lars, Many thanks for your reply~ Could you let me how to increase the block size? And, I am wondering why the interface is designed to only send data in blocks? Thanks!

Reply

Please read the discussion forum rules before posting.

Please log in to post a reply.

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.