Is Concatenating Matrices Possible for Different Mesh Sizes?

  • Thread starter Thread starter qwuasi
  • Start date Start date
  • Tags Tags
    Matrix
Click For Summary

Discussion Overview

The discussion revolves around the feasibility of concatenating matrices of different mesh sizes, specifically focusing on a 2-by-2 mesh and the potential extension to a 15-by-15 mesh. Participants explore the creation of matrices that represent nodes and their neighboring nodes based on shared edges in a grid structure.

Discussion Character

  • Exploratory
  • Technical explanation
  • Homework-related

Main Points Raised

  • One participant describes a 2-by-2 mesh and provides a matrix A, expressing a desire to create a new matrix I2 that includes nodes from neighboring elements.
  • Another participant seeks clarification on terminology, questioning what constitutes a node and a neighboring node, and whether the matrix A represents the mesh.
  • A participant outlines a homework statement regarding the generation of matrix A from a square grid and expresses the goal of creating a matrix that includes nodes from adjacent elements sharing edges.
  • Further clarification is provided about the nodes and edges, with an example illustrating how nodes are grouped based on their connections.
  • One participant claims to have completed an algorithm that works for N = 15 and confirms its correctness for N = 2, but expresses uncertainty about its performance for larger sizes.
  • Expressions of gratitude are shared, with one participant indicating that the results significantly contribute to their thesis work.

Areas of Agreement / Disagreement

Participants express varying levels of understanding and clarity regarding the definitions and processes involved. While some participants share successful implementations, there is no consensus on the correctness of the algorithm for sizes beyond N = 2, leaving the discussion unresolved regarding its broader applicability.

Contextual Notes

There are limitations in the clarity of definitions regarding nodes and neighboring nodes, as well as the assumptions made about the mesh structure. The discussion includes unresolved aspects of the algorithm's performance for larger mesh sizes.

qwuasi
Messages
5
Reaction score
0
I have a mesh (2-by-2) which is numbered 1:16.

[URL]http://www.flickr.com/photos/moorekwesi/5454749337[/URL]

A = [1 2 5 6; 3 4 7 8;9 10 13 14;11 12 15 16] ;

i want to create a matrix of the nodes from the element and it's neighbouring nodes.
This is for a 2-by-2 and hope to implement it also for say 15-by-15.
>>
The 2-by-2 results
I2 = [A(1,:) A(2,1) A(2,3) A(3,1) A(3,2) ;
A(2,:) A(1,2) A(1,4) A(4,1) A(4,2) ;
A(3,:) A(4,1) A(4,3) A(1,3) A(1,4) ;
A(4,:) A(3,2) A(3,4) A(2,3) A(2,4)]
 
Last edited by a moderator:
Physics news on Phys.org
Is this matlab? Also, all the jargon you're using makes what you want unclear to me. What do you consider a node and what do you consider a neighboring node? Is A your "2 by 2 mesh," whatever that is?
 


Homework Statement


Given a square grid ( n-by-n) with numbering 1:4n2 from the figure attached
(eg. n=2), the matrix: A = [1 2 5 6; 3 4 7 8;9 10 13 14;11 12 15 16] which corresponds
to the elements,ie row 1 corresponds to element 1,etc. is generated.i
want to create a new matrix such that for every element,i'll have the nodes
of the element and nodes from other elements which share a common edge.
This is the final result in this case is:
I2 = [A(1,:) A(2,1) A(2,3) A(3,1) A(3,2) ; A(2,:) A(1,2) A(1,4) A(4,1) A(4,2) ;
A(3,:) A(4,1) A(4,3) A(1,3) A(1,4) ; A(4,:) A(3,2) A(3,4) A(2,3) A(2,4)];

The Attempt at a Solution


I created matrix B (all the edges of A) and C (to get a column representation
of the edges).
B=[A(:,[1 3]) ; A(:,[2 4]) ; A(:,[1 2]) ; A(:,[3 4]) ] ' ;
C = reshape(B , 8 , [ ] ) ' ;
 

Attachments

  • physics.png
    physics.png
    5.3 KB · Views: 494
Last edited:
The nodes are colored BLUE and edges red,green,...Each element consist of the four nodes in that box. eg A(1) = {1 2 5 6},A(2) = {3 4 7 8}.The final solution is made of nodes in an element and and nodes (usually 2nodes) from neighbouring elements which share a common edge(straight line) eg for element 1: E(1) = {1 2 5 6 3 7 9 10}.
E(2) = {3 4 7 8 2 6 11 12}...likewise for E(3) and E(4).

I hope this helps.

Thank You
 
I just finished the algorithm. It can handle N = 15 instantly, and I verified it works correctly with N = 2. However, I'm not sure if it actually gets the right answers for anything beyond N = 2. Have fun.

Code:
N = 15;
for meshR = 1:N
    for meshC = 1:N
        r = (1:2)+(meshR-1)*2;
        c = (1:2)+(meshC-1)*2;
        ans1 = r + (c(1)-1)*N*2;
        ans2 = horzcat(ans1, ans1+N*2);
        if meshR < N %add contact to right
            ans1 = r(2) + 1 + (c(1)-1)*N*2;
            ans2 = horzcat(horzcat(ans2, ans1),ans1+N*2);
        end
        if meshR > 1 %add contact to left
            ans1 = r(1) - 1 + (c(1)-1)*N*2;
            ans2 = horzcat(horzcat(ans2, ans1),ans1+N*2);
        end
        if meshC < N %add contact above
            ans1 = r + c(2)*N*2;
            ans2 = horzcat(ans2, ans1);
        end
        if meshC > 1 %add contact below
            ans1 = r + (c(1)-2)*N*2;
            ans2 = horzcat(ans2, ans1);
        end
        I2{N*(meshC-1)+meshR} = ans2;
    end
end
%for k = 1:N^2
%   I2{k}
%end
 
Dear Sir,
Thank you so much for your assistance.For two months,i've struggled with this.It forms 20% of my thesis work.Seeing the results has given me good health.

Thank You.
 
qwuasi said:
Dear Sir,
Thank you so much for your assistance.For two months,i've struggled with this.It forms 20% of my thesis work.Seeing the results has given me good health.

Thank You.

No problem. If you want to cite me, pm me and I'll give you my real name. But I don't care if you use my algorithm without citation.
 

Similar threads

Replies
7
Views
2K
  • · Replies 14 ·
Replies
14
Views
2K
  • · Replies 17 ·
Replies
17
Views
3K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 20 ·
Replies
20
Views
5K
  • · Replies 17 ·
Replies
17
Views
11K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
7K
  • · Replies 15 ·
Replies
15
Views
2K