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.
Mesh element volume
Posted 2009年7月1日 GMT-4 17:07 Mesh Version 5.2 22 Replies
Please login with a confirmed email address before reporting spam
I have a material property having a different value in a domain and
it is function of individual volume of deformed mesh element and undeformed mesh
element.
Could you tell me how to get the volume of the mesh element?
In 2D, this may be the area of the each element. (Am I right?)
I appreciate your reply.
Thank you.
Yoon
Please login with a confirmed email address before reporting spam
I'm not sure I really catch fully your request, but to calculate the volume, surface, length you simply apply a "Integration Coupling Variable" on a Subdomain, Boundary, respectively Edge, you define the geometrical object onto where to integrate, and you integrate with the value "1".
It's not writen fully out but these GUI's are there to calculate th integration over dV=dx,dy,dz, dA=dx,dy, respectiely ds (or whatever Geometry Reference Coordinate you are using, length is slightly particular as it differs slightly depending on the number of DoFs seleted, have a read through the manuals).
Such an integratin can only be calulated once the volume is meshed and the solver initialised (use Solve Get Inital Value).
Now if you want to get the mesh difference before and after "deformation" you have either the "u,v,w" values to play with or you could perhaps turn on the "frame" (Physics Properties Crate Frame On) and then integrate on the different frames you define.
I would suggest that you write out the equations of what you want to do and then read through the manuals, start to test with a simple case.
Comsol, in opposition to most other FEM programmes is really a global physics PDE solver, so you should really switch to thinking physics from the PDE world side, not the first though fr those of us trained to use more traditional FEM programmes
Good luck
Please login with a confirmed email address before reporting spam
I noticed that ALE module can allow us to calculate the volume ratio of deformed and undeformed
mesh. The variable (dvol_ale/dvol) seems to give me the ratio for individual mesh element.
Please correct me if I'm wrong.
Thank you very much for your comments.
Yoon
Please login with a confirmed email address before reporting spam
ALE is certainly a good approach, particularly if you have larger deformations. I cannot confirm your formula, bacause I havent to now used it myself, but from the help I beleive you are right.
I have learned to carefully check every variable, as there is not always the full physical formula written out in the doc (COMSOL would need to rewrite a full physics book, but I still beleive they should).
This is my only concern with COMSOL, I'm still not 100% used to COMSOl's way to not write indexes, nor even integrals , in their formulas, and GUI's.
Good luck
Please login with a confirmed email address before reporting spam
In Comsol 4.1, is there a way to display or export the volume of each single mesh element (I am not speaking about the volume of a domain). I can display the size, h, but what about the volume of each mesh element? I could of course display h^3, which would assume that each element is a cube with edge length h. But I guess this is not really accurate.
Thanks for any help.
Alois
Please login with a confirmed email address before reporting spam
You can probably utilize the deformation gradient tensor to calculate the volume of each mesh element.
For the large deformation, the determinant of the tensor give you the ratio of deformed and undeformed volume.
For the small deformation, you can use strain to get the approximate value for that.
Wonseok
Please login with a confirmed email address before reporting spam
thanks for your suggestion. I do not have any mechanical deformation, since my problem uses the "Electric Currents" physics. I am just interested in the volume represented by each single mesh element.
I export the data to Matlab, where I need to compute an integral over a domain (Biot-Savart). This integral requires knowledge of a physical quantity at each mesh element (the current density) and the volume of each mesh element.
Exporting the current density is ok. But how do I export the volume of each mesh element?
Thanks. Alois
Please login with a confirmed email address before reporting spam
Please login with a confirmed email address before reporting spam
Yes I got the solution from Comsol support. Here is a summary of this support case:
My email #1:
I would like to ask you if there is a way to obtain the volume of a mesh element in Comsol 4.1. I know that there is a variable called "mesh element size", "h". According to the documentation of Comsol 3.5a:
"The variable h, available only in subdomains, represents the mesh element size (of the undeformed mesh), that is, the length of the longest edge of the element."
So in a first guess, I could assume that the mesh element is a cube of length h, and its volume is h^3. But this is of course not accurate. Is there a way to obtain the exact mesh element volume?
For example, let's assume that we have a domain with constant density. I would like to know the mass of each single mesh element. For this I need to know the volume of each single mesh element, such that I can multiply it with the density.
Comsol support answer #1:
You can use the variable "dvol" to determine the volume of the mesh elements. However, for non-block elements you need to multiply dvol with the following factors to get the correct volume.
Triangle : 1/2
Tetrahedron : 1/6
Prism : 1/2
Pyramid : 1/3
My email #2:
Thanks a lot for your help. Just to be sure that I understand you well:
by block elements, you mean quad and hex?
Is there a variable that describes the element type, e.g. var=1 for prism, var=2 for tetrahedron, var=3 for pyramid, etc?
Comsol support answer #2:
Yes.
Yes, you can use the variable "meshtype", which is equal to the number of element edges for each mesh element type, for example, 9 for prism and 6 for tetrahedron.
My email #3:
What I want to do does not work unfortunately. I drew a cylinder (radius r and height h) in Comsol, generated a mesh, and solved for a simple laminar flow through the cylinder. I then extracted the information for dvol and meshtype to two different text files. I then loaded the two files in Matlab, and ran a for loop over all the elements, checking which type
they are, and correcting the volume accordingly (Tetrahedron : 1/6, Prism : 1/2, etc.). Finally I sumed up all the single corrected volumes to obtain the total volume of the mesh. I ended up with a value which is completely wrong compared to the theoretical volume of the cylinder obtained by pi*r^2*h.
What is strange is that dvol and meshtype are given for each mesh point. How can a mesh point give any information about volume and element type?
There are points which belong to tetrahedrons and prisms at the same time. Nevertheless, they will either indicate tetrahedron or prism. Furthermore, what is the meaning of dvol for a mesh element? The volume of a point???
Thanks for clarifying this issue.
Comsol support answer #3:
When you export solution data to file you can specify the evaluation points for the export in the Advanced section. If you use the default settings you typically get several evaluation points for each element. This might be the reason for the incorrect value of the total volume resulting from your MATLAB script.
In this case you only want one evaluation point per element. To achieve this choose Gauss points in the Evaluate in list (and use Gauss point order 1).
Please login with a confirmed email address before reporting spam
from my understanding "dvol" is a mesh element scale factor (without units), not truly the volume of the element.
-----------
Good luck
Ivar
Please login with a confirmed email address before reporting spam
when multypling dvol with the corresponding correction factor (Triangle : 1/2; Tetrahedron : 1/6; Prism : 1/2; Pyramid : 1/3) and summing up the result over an entire domain (using the evaluation with Gauss points as described just above), you end up with the correct volume of this domain. So this variable represents a physical quantity, even if it is not obvious.
Alois
Please login with a confirmed email address before reporting spam
then I'm not sure how to use it within the GUI as the "summation over a domain" is over the nodes and not the elements from my understanding (integration of 1 = volume, summation is a number > number of elements)
while the GUI summation of dvol/average(meshtype) is far greater and the integration much smaller than the actual volume
--
Good luck
Ivar
Please login with a confirmed email address before reporting spam
I did not use it in the GUI, but I extracted the data (using Gauss evaluation of order 1) and then computed the summation in MATLAB. It might not work in the GUI,
Alois
Please login with a confirmed email address before reporting spam
Indeed it needs some further investigations ;)
--
Good luck
Ivar
Please login with a confirmed email address before reporting spam
I need to know the mesh element size in the 'extremely coarse' mesh and may also need to know the element sizes in the other mesh types such as 'normal', 'fine' etc. Is there any way I can know this?
Also, if I want to define my mesh element size, then are the numbers input into 'maximum element size' in the free mesh parameters in units of cm/mm?
Please login with a confirmed email address before reporting spam
In V4 by default its Si units hence [m], except if you change the base unit system of your model (top node). You can change the default geoemtry units from [m] to [mm] or whatever, this remains limited to the geometry representation, the physics remain in default [m] the mesh normally follos the geoemtryx units, but there you have the m or mm appearing to the right of the max/min sizes
Mostly the units are mentioned in the GUI (still a few exceptions were its missing)
I believe in V3 the default was [m] (or the main pysics based units) for all not sure any longer
--
Good luck
Ivar
Please login with a confirmed email address before reporting spam
I amtrying to find the volume of a geometry, or rather, the part of it where S < 0. So I figured that I could define an integration operator that integrates over the desired domain (this part works as I use it for other purposes), and evaluate something like:
intop1((S<0)*dvol*<some magic based on meshinfo>)
But I cannot find enough info in this thread to solve this puzzle. I'm using the GUI, so java/matlab solutions is not what I want to use.
Anybody?
Thanks,
Fred-Johan
Please login with a confirmed email address before reporting spam
in comsol when you integrate the dx*dy*dz is implicit, and controlled by COMSOL so there is no reason to use twice dvol, its implicit there, if you want the volume of a domain, you integrate over the domain the argument "1", so if you use a boolean operator i.e (S<0) and integrate that over the domain, you will get the total volume where the condition is "1". It's as simple as that ;)
Note COMSOL has many implicit notations, these are quite common to miss, it took me quite some time to really understand the double game of scalar variables, fields, implicit summation and integration over entities ...
--
Good luck
Ivar
Please login with a confirmed email address before reporting spam
Please login with a confirmed email address before reporting spam
- dvol (for a set of coordinates x,y z)
- meshtype (for a set of coordinates x,y,z)
To obtain the volume of a mesh element (in Matlab), I multiply "dvol" at coordinate (x,y,z) by the appropriate factor depending on the value of "meshtype" at that same coordinate.
"meshtype" is equal to the number of element edges for each mesh element type, for example, 9 for prism and 6 for tetrahedron.
The factors are:
Triangle : 1/2
Tetrahedron : 1/6
Prism: 1/2
Pyramid : 1/3
Please login with a confirmed email address before reporting spam
My 2 cents: The following lines in matlab computes the volume from two imported arrays meshtype and dvol as discussed above (tested to yield the same value as integrating over 1 in comsol):
meshtype(meshtype==3) = 1/2;
meshtype(meshtype==4) = 1/3;
meshtype(meshtype==6) = 1/6;
meshtype(meshtype==9) = 1/2;
volume = meshtype.*dvol;
BR
Magnus
Please login with a confirmed email address before reporting spam
For the comsol guys; I do not understand why it is so difficult to combine the current output of some package as an input for the magnetic field package. That's why we have to make this detour ...
Please login with a confirmed email address before reporting spam
workaround:
if I do ...
Results>3dplotGroup>mesh
DataSet: Mesh
I can see, with for example Volume, the Element-Type. For all but Tetrahedron the plot is empty : So I know that my factor is always 1/6.
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.
Suggested Content
- FORUM Curl Element
- KNOWLEDGE BASE Understanding, and changing, the element order
- BLOG Improving Your Meshing with Partitioning
- KNOWLEDGE BASE Failed to respect edge element on geometry edge
- BLOG How to Inspect Your Mesh in COMSOL Multiphysics®