Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

about the numbers of DOFs and nodes

Please login with a confirmed email address before reporting spam

Hi! I’m using livelink for matlab to extract some information of mesh and dofs. Here is my question. I built a cubic model with a structured mesh, which contained 3x3x3=27 elements. Boundary condition was not applied yet, and the model had not been computed. In livelink for matlab, I used "mphmatrix", "mphxmeshinfo" and "mphmeshstats" to retrieve information. Here follow the results.

ME=mphmatrix(model,'sol1','out',{'K','L','M','N'},'initmethod','sol','initsol','zero')

ME =

struct with fields:

K: [624×624 double]
L: [624×1 double]
M: [0×1 double]
N: [0×624 double]

info = mphxmeshinfo(model)

info =

struct with fields:

soltag: 'sol1'
ndofs: 624
fieldnames: {'comp1.u'}
fieldndofs: 624
meshtypes: {4×1 cell}
geoms: {'geom1'}
dofs: [1×1 struct]
nodes: [1×1 struct]
elements: [1×1 struct]

[r,c]=size(info.nodes.coords)

r =3 c =262

[stats,data]=mphmeshstats(model)

stats =

struct with fields:

            meshtag: 'mesh1'
            geomtag: 'geom1'
            component: 'comp1'
            isactive: 1
            hasproblems: 0
            iscomplete: 1
            sdim: 3
            contributing: {'solid'  'ht'}
            secondorderelements: 0
            types: {'edg'  'hex'  'quad'  'vtx'}
            numelem: [36 27 54 8]
            qualitymeasure: 'skewness'
            minquality: 1
            meanquality: 1
            qualitydistr: [20×1 double]
            minvolume: 1
            maxvolume: 1
             volume: 27
            maxgrowthrate: 1
            meangrowthrate: 1

data = struct with fields:

     types: {'edg'  'hex'  'quad'  'vtx'}
    vertex: [3×64 double]
      elem: {[2×36 int32]  [8×27 int32]  [4×54 int32]  [0 10 16 19 44 47 53 63]}
elementity: {[36×1 int32]  [27×1 int32]  [54×1 int32]  [8×1 int32]}

The size of "info.nodes.coords" shows that there are 262 nodes in the model, while the results of "mphxmeshinfo" and "mphmatrix" show that the number of degrees of freedom is 624 and the size of stiffness matrix is 624x624. I think the number of dofs should be 3x262=786, but why the number of dofs given by "mphxmeshinfo" is 624?


2 Replies Last Post Jun 13, 2022, 12:31 a.m. EDT
Remi Magnard COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 2 years ago Jun 10, 2022, 7:09 a.m. EDT

Dear Chui Ding,

the reason of the difference between the number nodes and dofs comes from the default discretization type for solid mechanics, which is set to quadratic serendipity. This discretization leads to 6x3 less dofs per element compare to quadratic lagrange (the mid-point on each faces are removed). If you switch the discretization to quadratic lagrange you will get a perfect match between dofs and nodes number (multiply by the number of dependent variables). To change the discretization, in the COMSOL Desktop, in the Solid Mechanics node, expamd the section Discretization.

To visualize the difference between the element nodes and the location of the dofs you can run the following commands:

info = mphxmeshinfo(model);
plot3(info.nodes.coords(1,:),info.nodes.coords(2,:),info.nodes.coords(3,:),'b+')
hold on;
plot3(info.dofs.coords(1,:),info.dofs.coords(2,:),info.dofs.coords(3,:),'r.','MarkerSize',10)

I hope this will help!

Rémi Magnard

Dear Chui Ding, the reason of the difference between the number nodes and dofs comes from the default discretization type for solid mechanics, which is set to quadratic serendipity. This discretization leads to 6x3 less dofs per element compare to quadratic lagrange (the mid-point on each faces are removed). If you switch the discretization to quadratic lagrange you will get a perfect match between dofs and nodes number (multiply by the number of dependent variables). To change the discretization, in the COMSOL Desktop, in the Solid Mechanics node, expamd the section Discretization. To visualize the difference between the element nodes and the location of the dofs you can run the following commands: info = mphxmeshinfo(model); plot3(info.nodes.coords(1,:),info.nodes.coords(2,:),info.nodes.coords(3,:),'b+') hold on; plot3(info.dofs.coords(1,:),info.dofs.coords(2,:),info.dofs.coords(3,:),'r.','MarkerSize',10) I hope this will help! Rémi Magnard

Please login with a confirmed email address before reporting spam

Posted: 2 years ago Jun 13, 2022, 12:31 a.m. EDT
Updated: 2 years ago Jun 13, 2022, 12:32 a.m. EDT

Dear Chui Ding,

the reason of the difference between the number nodes and dofs comes from the default discretization type for solid mechanics, which is set to quadratic serendipity. This discretization leads to 6x3 less dofs per element compare to quadratic lagrange (the mid-point on each faces are removed). If you switch the discretization to quadratic lagrange you will get a perfect match between dofs and nodes number (multiply by the number of dependent variables). To change the discretization, in the COMSOL Desktop, in the Solid Mechanics node, expamd the section Discretization.

To visualize the difference between the element nodes and the location of the dofs you can run the following commands:

info = mphxmeshinfo(model); plot3(info.nodes.coords(1,:),info.nodes.coords(2,:),info.nodes.coords(3,:),'b+') hold on; plot3(info.dofs.coords(1,:),info.dofs.coords(2,:),info.dofs.coords(3,:),'r.','MarkerSize',10)
I hope this will help!

Rémi Magnard

Thanks for your answer, problem sovled! I have retrieved the node information and the elastic modulus and possion ratio are known. Could you tell me how to calcultate the stiffness matrix of a quadratic lagrange element? I didn't find it in the manual. Thanks again!

>Dear Chui Ding, > >the reason of the difference between the number nodes and dofs comes from the default discretization type for solid mechanics, which is set to quadratic serendipity. This discretization leads to 6x3 less dofs per element compare to quadratic lagrange (the mid-point on each faces are removed). >If you switch the discretization to quadratic lagrange you will get a perfect match between dofs and nodes number (multiply by the number of dependent variables). To change the discretization, in the COMSOL Desktop, in the Solid Mechanics node, expamd the section Discretization. > >To visualize the difference between the element nodes and the location of the dofs you can run the following commands: > > info = mphxmeshinfo(model); > plot3(info.nodes.coords(1,:),info.nodes.coords(2,:),info.nodes.coords(3,:),'b+') > hold on; > plot3(info.dofs.coords(1,:),info.dofs.coords(2,:),info.dofs.coords(3,:),'r.','MarkerSize',10) > >I hope this will help! > >Rémi Magnard Thanks for your answer, problem sovled! I have retrieved the node information and the elastic modulus and possion ratio are known. Could you tell me how to calcultate the stiffness matrix of a quadratic lagrange element? I didn't find it in the manual. Thanks again!

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.