GenerateMesh not working in matlab 2016

I can't use generatemesh in my 2016 matlab. Is there a problem with it or is the version too old for this funciton? Is there any way to do the genereatemesh with a function created by me? We need to make a study where we use finite element method ans Gauss. For that we need to use nodes in a specific form and calculate the heat flux for each one. So in this generatemesh eah node has to have information for itself.

 採用された回答

Steven Lord
Steven Lord 2018 年 4 月 26 日

0 投票

The item at the end of the documentation page for generateMesh indicates it was introduced in release R2015a. There are a couple different potential reasons why you would not be able to successfully use this function.
  1. It is part of Partial Differential Equations Toolbox, so you will need to have that product installed and licensed to use this function. You can check the ver function to determine if you have it installed.
  2. This function requires its first input to be a PDEModel created with createpde. You cannot simply call it with a matrix or array as the first input.
If neither of those issues apply to your attempted use of this function, please show us what happens (with a SMALL section of code, ideally) when you try to use it. If you receive a warning or error message when you try to run that code, show the full text (everything in orange or red) of the warning or error message.

7 件のコメント

Diogo Ferreira
Diogo Ferreira 2018 年 4 月 27 日
Thank's for the help, I do have the toolbox instaled, but i still got a problem. The purpose of the project is to create a model of heat transfer for a specific form. The "createpde" already gives information that has to be made by me. I just wanted the "generatemesh" to make the mesh with a number of nodes that i could choose and that each nodde could contain information for the final plot
Ravi Kumar
Ravi Kumar 2018 年 4 月 27 日
Are you saying "createpde" works on your installation of MATLAB and "generateMesh" doesn't? That would be unusual and is not an expected behavior.
As Steve said, providing a code example along with the error/warning that you are encountering would help us understand the issue you are facing.
Diogo Ferreira
Diogo Ferreira 2018 年 4 月 27 日
Steven Lord
Steven Lord 2018 年 4 月 27 日
On line 11 of your bloco code, you create g using decsg. That function returns the "Decomposed geometry matrix, returned as a matrix of double-precision numbers."
As per the second bullet point in my answer, generateMesh requires its first input to be a PDEModel object, not a numeric matrix.
I believe what your code is missing is a call to geometryFromEdges. I think the first example on that documentation page can serve as a model for your code. When I ran that code then called generateMesh(model) and pdemesh(model) I saw the mesh.
Diogo Ferreira
Diogo Ferreira 2018 年 4 月 27 日
Thanks for the help Steven. You helped me a lot. Meanwhile another problem appeared. When trying to make the quadratic mesh, I only get triangules instead of regular rectangules. How can I fix this?
Steven Lord
Steven Lord 2018 年 4 月 27 日
The documentation for generateMesh starts off with the description "Create triangular or tetrahedral mesh". I wouldn't expect it to try to mesh with rectangles. In the "More About" section on that page it describes that triangles representing quadratic elements have nodes at the triangle corners and edge centers, and that matches what I see when I update the graphics to include markers for the nodes. [I'm using release R2018a to run this code, but I think I'm not using anything newer than your release.]
>> model = createpde;
>> r1 = [3 4 -0.5 0.5 0.5 -0.5 -0.8 -0.8 0.8 0.8];
>> r2 = [3 4 -0.05 0.05 0.05 -0.05 -0.4 -0.4 0.4 0.4];
>> gdm = [r1; r2]';
>> g = decsg(gdm, 'R1-R2', ['R1'; 'R2']');
>> geometryFromEdges(model, g);
>> generateMesh(model, 'GeometricOrder', 'quadratic');
>> h = pdemesh(model);
>> h(1).Marker = 'o';
>> h(2).Marker = '^';
So I don't think you can "fix" this; I don't think anything's wrong, unless I'm misunderstanding your concern.
Diogo Ferreira
Diogo Ferreira 2018 年 4 月 28 日
Thanks again Steven. I didn't tell you my problem clearly. For that I'm sorry for waisting your time. Now I know that for my project I can't use this function because i need the nodes to be in especific positions with a certain lenght between them. Nevertheless thanks for your help. I'll probabily ask something here in the future. I'll look for your answer ;^) Take care.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by