Discussion Forum

calculating average element size

Topics: Mesh

Thread index  |  Previous thread  |  Next thread  |  Start a new discussion

RSS FeedRSS feed   |   Email notificationsTurn on email notifications   |   16 Replies   Last post: February 23, 2013 12:41pm UTC
Amr Al Abed

Amr Al Abed

February 18, 2011 12:29am UTC

calculating average element size

Hi,

I am trying to characteise the effect of mesh quality and element size on the solution of a model. I have generated a standard and several refined meshes using an external software (Simpleware) and imported them to Comsol.

I am using q = meshqual(fem.mesh); to calculate the mesh quality.

Is there a similar command or calculate the average element size?

I have tried a subdomain plot of "h" the element size, exporting the plot data to Matlab and calculating the average. However I have noticed the number of elements in the output file is alot more than the real number of elements.

I am not sure how the export plot data works in this case? Is it exporting the element size at each vertex?

Thanks

Amr

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Ivar Kjelberg

Ivar Kjelberg

February 18, 2011 7:32am UTC in response to Amr Al Abed

Re: calculating average element size

Hi

I'm interested to understand and hear in which version, and how you import the mesh and how you then get COMSOL to use it: as geometry or as entities or as mesh ?

--
Good luck
Ivar

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Amr Al Abed

Amr Al Abed

February 18, 2011 7:52am UTC in response to Ivar Kjelberg

Re: calculating average element size

Hi Ivar,

I import the mesh as an .mphtxt file - which is generated by Simpleware and I use the imported mesh to solve the model . I am using V3.5a

However, the same question about calculating the average element size applies to any simple geometry drawn and meshed in Comsol.

I know I can set the element size when generating the mesh in Comsol. But how do I check that the actual element size in the mesh I generate in Comsol matches what I specified?

Thanks

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Ivar Kjelberg

Ivar Kjelberg

February 18, 2011 9:17am UTC in response to Amr Al Abed

Re: calculating average element size

Hi

"h" is the mesh element size but it's local to be understand as "h_i" where _i represent every "i" mesh element.

So basically I would say it's taking the average of "h" over the domain, something like intop1(h)/intop1(1), where intop1() is your Integration Coupling variable (ported back to 3.5, that's getting oldish for me ;) in V4 it's simply aveop1(h)

you have also something like a "dvol" if I remember right in addition to "qual" in 3.5

--
Good luck
Ivar

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

sshahir

sshahir

June 3, 2011 2:05am UTC in response to Ivar Kjelberg

Re: calculating average element size

Hi,

I am using free Triangular mesh, and need to determine the area of each triangle for calculating ds. I have tried to use average h_i(mesh element size), but it looks like it is not exact solution. Can you please let me know how I can calculate the area of each triangle within Triangular mesh?

Thanx,
Shahed

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Joel Kpahou

Joel Kpahou

July 12, 2011 7:49am UTC in response to sshahir

Re: calculating average element size

i'm interested how can you handle the obtained mesh from simpleware in Comsol??

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Yang Jiao

Yang Jiao

April 27, 2012 6:40pm UTC in response to Ivar Kjelberg

Re: calculating average element size

Can I have a question that what does it mean by "mesh size" when describing a Free Tetrahedral mesh? Which dimension is it talking about since it has a unit of "m"?

I prefer to know the volume of each mesh in my case for calculating the total enthalpy in the final product.

Thanks for answering Ivar.

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Ivar Kjelberg

Ivar Kjelberg

April 27, 2012 8:40pm UTC in response to Yang Jiao

Re: calculating average element size

Hi
there is something I do not understand, why do you all want to know the volume or area of the mesh elements ? In Comsol one define the physics on the geoemtrical Entities,so the results are also obtained by integrating over the entities (doamins and boundaries). A mesh is finally only the discretisation used, and it might change, the entities, far less.

It's like when you digitalise a analogue signal, for example some music. Finally one want the melody as results, not the size of each sample used to discretized the signal. If the quality is not good enough, OK one decides to use a faster and more detailed discretisation, but the end esire is the quality of the final sound.

or have I missed something ?

--
Good luck
Ivar

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Yang Jiao

Yang Jiao

April 30, 2012 10:02pm UTC in response to Ivar Kjelberg

Re: calculating average element size

Thanks for your reply.

In my case, I would like to know the total enthaply inside my food material in joule heating module.

After building up a heat transfer module and solved, I can see the temperature distribution, and also, I can export the enthalpy data. However, the unit of "enthalpy" and "total enthalpy" are both with a unit of J/kg. So I am wondering shall I know the volume of each mesh, and then calculate the mass of each mesh, in order to obtain the enthalpy within each mesh and add them up? or just simply add all them up and them multiply by the total mass of product?

Thanks, let me know if it is not clear enough.

Yang




Hi
there is something I do not understand, why do you all want to know the volume or area of the mesh elements ? In Comsol one define the physics on the geoemtrical Entities,so the results are also obtained by integrating over the entities (doamins and boundaries). A mesh is finally only the discretisation used, and it might change, the entities, far less.

It's like when you digitalise a analogue signal, for example some music. Finally one want the melody as results, not the size of each sample used to discretized the signal. If the quality is not good enough, OK one decides to use a faster and more detailed discretisation, but the end esire is the quality of the final sound.

or have I missed something ?

--
Good luck
Ivar


Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Ivar Kjelberg

Ivar Kjelberg

May 1, 2012 4:52am UTC in response to Yang Jiao

Re: calculating average element size

Hi

Well forget the "mesh" it's "only" the discretization. COMSOL looks after the integration. You should work on the "entities" where you have defined your physics, in particular the "domains" (volume in 3D, surfaces in 2D ...) and the boundaries (surfaces in 3D, edges in 2D ...)

If you solve the HT and want the total entalpy, you integrate over the domain(s) of interest "Cp*rho*T"

You shoul note that COMSOl calles these dependent variables "variables" but they are in fact "fields" its Cp(x,y,z,t) and rho(x,y,z,t) and T(x,y,z,t) (or whatever corresponds to your coordinate system and if used time response). And these are in dimension of the mesh elements (hence often you see densities per kg or per m^3, so most "variables" must be integrated over the domains (volumes) to get macroscopic values out.

For COMSOl you define the physics and BC on the Entities, and you postprocess the entities, the mesh is the discretization or sampling of your "signal/model" it must meet the Nyquist of mesh quality criteria, that is all). You can concentrate on the true physics and not on the FEM math with COMSOL, that is what is so nice with it ;)

--
Good luck
Ivar

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Yang Jiao

Yang Jiao

May 1, 2012 5:26pm UTC in response to Ivar Kjelberg

Re: calculating average element size

Hi Ivar,

Thanks. As per my understanding, the mesh we made for discretilization is not important at all, can you give me an example of how to calculate the total energy absorbed in my material? The following data is exported as "total enthalpy" with a unit of J/kg. I took two time point for reference.

As far as I know the enthalpy distribution is fairly different at every different location in the material, but how to integrate them in comsol or any other postprocessing software? Can you show me simply how to do it?

Thanks,

% x
0.071
0.071
0.069781614
0.066606098
0.070207608
0.068316062

y
-0.04
-0.04
-0.044783645
-0.041805078
-0.043901277
-0.046817275

z
0.1116
0.107269484
0.1116
0.1116
0.106316936
0.107818497

jh.H0 (J/kg) @ t=0
520322.6718
520327.721
520337.4573
520306.691
520351.3471
520336.7744

jh.H0 (J/kg) @ t=900
858315.0763
862184.7099
860672.0054
861906.5826
865079.9856
864478.9603

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Ivar Kjelberg

Ivar Kjelberg

May 1, 2012 7:22pm UTC in response to Yang Jiao

Re: calculating average element size

Hi

I do normally everything within the GUI, check the example, if you need the time evolution, or difference between two times you need to fidle with the at() operator in the postprocessing

--
Good luck
Ivar

Attachments:   HTenthalpy.mph  

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Yang Jiao

Yang Jiao

May 2, 2012 5:41pm UTC in response to Ivar Kjelberg

Re: calculating average element size

I am sorry Ivar, I am not open the file you attached. I tried several different machine and it still does not work. I am using Comsol 4.2, Can you check your file and upload it again? Thanks!!!

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Ivar Kjelberg

Ivar Kjelberg

May 2, 2012 9:26pm UTC in response to Yang Jiao

Re: calculating average element size

Hi

sorry I have only 4.2a installed, I agree the chase of versions is tricky and makes life difficult for exchanges, computer time ...

--
Good luck
Ivar

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Yang Jiao

Yang Jiao

May 2, 2012 11:29pm UTC in response to Ivar Kjelberg

Re: calculating average element size

Thanks anyway, hope I can find some other people open it for me..

Can you try post a picture for the procedures doing that, I mean, calculate the enthalpy in GUI?

Thanks so much, Ivar!

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Peng Xie

Peng Xie

February 23, 2013 6:12am UTC in response to Ivar Kjelberg

Re: calculating average element size

Hi Ivar,
I am using artificial diffusion in comsol . as the effect of the articial diffusion is correlated with the mesh size, therefore I am really interested in how can I know the mesh size. I have tired the method you described here but no luck. Is there any embedded way that allows us to obtain the average mesh size?

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Ivar Kjelberg

Ivar Kjelberg

February 23, 2013 12:41pm UTC in response to Peng Xie

Re: calculating average element size

Hi

I believe you have only the average "h" mesh size (field its h(x,y,z) ;) at disposal, as meshes can be rather anisotropic, sometimes I do too miss some sort of hx,hy,hz, the three components of "h"

COMSOL itself have different artificial diffusion methods, depending on the physics, check carefully the solver section of the doc

--
Good luck
Ivar

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse


Rules and guidelines