How can I define the temperature in 2D domain at location x,y [rather than nodal locations] for steady state or transient solution?

2 views (last 30 days)
I have been able to duplicate the results for the steady state and transient responses for the problem defined at
This example includes code to plot the temperature at a specific point in the block, in this case near the center of the right edge, as a function of time.
I would be interested to define the temperature and temperature history at any x,y location for the defined block with the slot in it- for example at the top right corner of the slot.

Accepted Answer

Shishir Reddy
Shishir Reddy on 23 Aug 2024
Hi John
Finding the temperature at an arbitrary point ((x, y)) within a finite element mesh can be challenging because directly calculating the temperature at a random (x, y) point would require identifying the element containing the point and using interpolation functions, which can be complex and computationally intensive.
Instead of calculating the temperature at the exact (x, y) point, it can be approximated to the temperature at the nearest node. This is an efficient approximation because it reduces the complexity and also gives closer estimate to the temperature if the mesh is sufficiently refined.
If observed closely, it can be understood that same method is followed in the documentation in finding the temperature at the centre of the right edge as well.
% Function to find the index of the nearest node
getClosestNode = @(p, x, y) find(min((p(1,:) - x).^2 + (p(2,:) - y).^2) == (p(1,:) - x).^2 + (p(2,:) - y).^2);
% Find the index of the nearest node
nid = getClosestNode(p, x_target, y_target);% (x_target, y_target) are the coordinates of the specific position we would like to calculate the temperature at.
To find the temperature at top right corner of the slot, substitute x_target = 0.5 and y_target = 0.8.
I hope this helps.
  1 Comment
John McGrath
John McGrath on 23 Aug 2024
Hi Shishir,
Thank you for your response. I tried your suggestion and got error messages as follows:
Undefined function 'minus' for input arguments of type 'matlab.graphics.GraphicsPlaceholder'.
Error in untitled78>@(p,x,y)find(min((p(1,:)-x).^2+(p(2,:)-y).^2)==(p(1,:)-x).^2+(p(2,:)-y).^2) (line 55)
getClosestNode = @(p, x, y) find(min((p(1,:) - x).^2 + (p(2,:) - y).^2) == (p(1,:) - x).^2 + (p(2,:) - y).^2);
Error in untitled78 (line 57)
nid = getClosestNode(p, x_target, y_target);% (x_target, y_target) are the coordinates of the specific position we would
like to calculate the temperature at.

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Products


Release

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!