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.

Outputting only the dependent variables using mphgetu while solving multiple physics problems

Please login with a confirmed email address before reporting spam

Please find the attached models.

I am solving a 2D cantilever problem to get displacements. I discretize my domain with 4 elements and I generate the matlab code to output the displacements. When I use one physics (See attached single_solid_mechanics_physics.m and single_solid_mechanics_physics.mph), I use the code below to output my x and y displacement which is 12*1 matrix from the matlab file.

U = mphgetu(model, 'soltag', 'sol1');

However, when I use two physics (See attached two_solid_mechanics_physics.m and two_solid_mechanics_physics.mph), I carried out the same procedure and I use

U2 = mphgetu(model, 'soltag', 'sol1');

to output my displacement. I anticipate to get 24*1 matrix which will be u and v displacment for the two physics.

But I got 38*1 matrix. I have tried to figure this out but to no avail. Please, help me. I only need the depedent variables. That is, u and v displacment for the two physics. How can I output only the dependent variables while solving this class of problem?



4 Replies Last Post 30 oct. 2019, 06:17 UTC−4
Henrik Sönnerlind COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 5 years ago 29 oct. 2019, 03:43 UTC−4
Updated: 5 years ago 28 oct. 2019, 23:43 UTC−4

Hi Samuel,

From the DOF count, my guess is that you use different discretization orders in the two cases.

Regards,
Henrik

-------------------
Henrik Sönnerlind
COMSOL
Hi Samuel, From the DOF count, my guess is that you use different discretization orders in the two cases. Regards, Henrik

Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 5 years ago 29 oct. 2019, 04:36 UTC−4

Henrik is correct.

After running the two_solid_mechanics_physics.m file I can see that the first physics use linear elements and the second use quadratic seredipity elements (the latter is the deafult).

If you indeed wish to use only linear elements it may be easier to interpret the result you get from mpheval instead of the data you get from mphgetu.

-------------------
Lars Gregersen
Comsol Denmark
Henrik is correct. After running the two_solid_mechanics_physics.m file I can see that the first physics use linear elements and the second use quadratic seredipity elements (the latter is the deafult). If you indeed wish to use only linear elements it may be easier to interpret the result you get from mpheval instead of the data you get from mphgetu.

Please login with a confirmed email address before reporting spam

Posted: 5 years ago 29 oct. 2019, 08:57 UTC−4
Updated: 5 years ago 29 oct. 2019, 04:57 UTC−4

Thank you so much Henrik and Lars. Now I have made the correction and I now have 24 elements. Please, find attached. My guess about the order of output U is this: u,v, u2,v2. Is that correct?

Thank you so much Henrik and Lars. Now I have made the correction and I now have 24 elements. Please, find attached. My guess about the order of output U is this: u,v, u2,v2. Is that correct?


Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 5 years ago 30 oct. 2019, 06:17 UTC−4

Hi Samuel

I get this order:

>> info=mphxmeshinfo(model)

info = 

  struct with fields:

        soltag: 'sol1'
         ndofs: 24
    fieldnames: {2×1 cell}
    fieldndofs: [2×1 double]
     meshtypes: {3×1 cell}
         geoms: {'geom1'}
          dofs: [1×1 struct]
         nodes: [1×1 struct]
      elements: [1×1 struct]

>> info.dofs.dofnames

ans =

  4×1 cell array

    {'comp1.u' }
    {'comp1.u2'}
    {'comp1.v' }
    {'comp1.v2'}
-------------------
Lars Gregersen
Comsol Denmark
Hi Samuel I get this order: >> info=mphxmeshinfo(model) info = struct with fields: soltag: 'sol1' ndofs: 24 fieldnames: {2×1 cell} fieldndofs: [2×1 double] meshtypes: {3×1 cell} geoms: {'geom1'} dofs: [1×1 struct] nodes: [1×1 struct] elements: [1×1 struct] >> info.dofs.dofnames ans = 4×1 cell array {'comp1.u' } {'comp1.u2'} {'comp1.v' } {'comp1.v2'}

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.