Note: This discussion is about an older version of the COMSOL Multiphysics® software. The information provided may be out of date.

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.

Ideal mesh for a regular grid export

Please login with a confirmed email address before reporting spam

Dear Comsol community,

I have a simple 3D electrostatic configuration of two separated point charges in free space. What I want to do is solving the poison-equation and exporting the data in small cubic region between the point charges on a regular grid.

What is the optimal mesh for exporting on a regular grid with about 201^3 points?

Since the error of the FE-method is minimal (vanishing) on the nodes of the mesh-elements I think it would be perfect to have a regular mesh with nodes exactly on the points of the regular grid. I found no way to achieve this yet and I would be thankful for any kind of help giving me a good exported result.

6 Replies Last Post Jun 5, 2012, 10:45 a.m. EDT
Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago May 18, 2012, 10:25 a.m. EDT
Hi

I'm not convinced that the results are that much more precise "at the node"s than" in between". For me on average they remain all valid.

What might disturb and add less "validity" is regions with coarse mesh and high gradients.

The mesh is like the digital sampling of music or any time sequence signal, you need to resepct the Nyquist criteria, or its homonyme for resolving steep gradients. Sound gets rather metallic if you have only 5, or less, samples per periode

I'm sure that most of you on the FORUM would never undersample a nice music recording, but many accepts to undersample your FEM ;) But it's the same criteria, or almost ...

I would say for your case box the region with interior boundries, try a default mesh and look at the gradients, then refine the "box" until you are happy (you might need to mesh it manually with a sweep mesh or other all depends on the variables and their behaviour, incl. the symmetry, or none of your problem) and export it as is, either in raw or in interpolated mode.


--
Good luck
Ivar
Hi I'm not convinced that the results are that much more precise "at the node"s than" in between". For me on average they remain all valid. What might disturb and add less "validity" is regions with coarse mesh and high gradients. The mesh is like the digital sampling of music or any time sequence signal, you need to resepct the Nyquist criteria, or its homonyme for resolving steep gradients. Sound gets rather metallic if you have only 5, or less, samples per periode I'm sure that most of you on the FORUM would never undersample a nice music recording, but many accepts to undersample your FEM ;) But it's the same criteria, or almost ... I would say for your case box the region with interior boundries, try a default mesh and look at the gradients, then refine the "box" until you are happy (you might need to mesh it manually with a sweep mesh or other all depends on the variables and their behaviour, incl. the symmetry, or none of your problem) and export it as is, either in raw or in interpolated mode. -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago May 18, 2012, 11:25 a.m. EDT
Hello and thanks for your reply,

as far as i understood fem the solution on the nodes is exact within the choosen subspace (galerkin-method) and you end up with an additional polynomial interpolation error beetween the nodes - this might be wrong but it's the reason why i thought having nodes on export points and not in between turns out to be a good idea.

When i export a "freemesh solution" on a regular grid and use the data on the gridpoints to calculate frist and second order partial derivatives with the 5-point-stencil method i experience getting a lot of additional noise with growing finess of my regular grid. Since the analytical solution of my test problem (which is just a dipole) is very smooth i thought the interpolation method used by comsol to determine values between nodes for export causes my problems and i am really desperate to circumvent this.

For export i use:
points to eval in: Grid
format: spreadsheet
xy,z,: range(...) // the way this generates a regular grid
full precision
eval in: lagrange points
resolution: finer
smoothing: internal

I would be very thankfull for any further hints. To make my "noise problem" more clear i attach two plots which were generated out of the same solution with different export finess. I am aware that having a coarses export grid surpresses noise in further calculations but i am really baffled by fact that the coarse export gives much more accurate end results.

Thank you!

Hello and thanks for your reply, as far as i understood fem the solution on the nodes is exact within the choosen subspace (galerkin-method) and you end up with an additional polynomial interpolation error beetween the nodes - this might be wrong but it's the reason why i thought having nodes on export points and not in between turns out to be a good idea. When i export a "freemesh solution" on a regular grid and use the data on the gridpoints to calculate frist and second order partial derivatives with the 5-point-stencil method i experience getting a lot of additional noise with growing finess of my regular grid. Since the analytical solution of my test problem (which is just a dipole) is very smooth i thought the interpolation method used by comsol to determine values between nodes for export causes my problems and i am really desperate to circumvent this. For export i use: points to eval in: Grid format: spreadsheet xy,z,: range(...) // the way this generates a regular grid full precision eval in: lagrange points resolution: finer smoothing: internal I would be very thankfull for any further hints. To make my "noise problem" more clear i attach two plots which were generated out of the same solution with different export finess. I am aware that having a coarses export grid surpresses noise in further calculations but i am really baffled by fact that the coarse export gives much more accurate end results. Thank you!


Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago May 18, 2012, 2:54 p.m. EDT
Hi

I would suggest to ask support directly as these people are the only really knowing all details of whats being done inside COMSOL.

One way to set up a cube with your nomber of nodes is to draw a cube, mesh 4 edges with 201 points, use a mapped mesh on the internal boundary, then sweep with dimension 201 elements. Convert all external boundary elements to tri and mesh default the outside air region. Then export your result.

I'm still woundering why you need to export cant you set up xour equations inside the COMSOL gui and use COMSOL derivatives to get your final results ? Perhaps by increasing the discretzation to.

--
Good luck
Ivar
Hi I would suggest to ask support directly as these people are the only really knowing all details of whats being done inside COMSOL. One way to set up a cube with your nomber of nodes is to draw a cube, mesh 4 edges with 201 points, use a mapped mesh on the internal boundary, then sweep with dimension 201 elements. Convert all external boundary elements to tri and mesh default the outside air region. Then export your result. I'm still woundering why you need to export cant you set up xour equations inside the COMSOL gui and use COMSOL derivatives to get your final results ? Perhaps by increasing the discretzation to. -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago May 18, 2012, 4:39 p.m. EDT
Hello,

i meshed my region of interest as you described and ended up how i wanted to ... thanks a lot! Can't tell if it brings better results since simulation is running right now but i will let you know.

I investigate dynamics of particles in extern fields. I know there is a particle tracing module but on the one hand i didn't find a way to get third order derivates out of comsol which i needed for the actual force and on the other hand i prefer writing such kind of simulations in c++ using gsl and other libs and get more control over whats going on. When investigations goes further into some none-classic stuff we are lost with a comsol solution anyway (i guess). So politics are just using comsol for solving poisson.

Thanks for you help!
Hello, i meshed my region of interest as you described and ended up how i wanted to ... thanks a lot! Can't tell if it brings better results since simulation is running right now but i will let you know. I investigate dynamics of particles in extern fields. I know there is a particle tracing module but on the one hand i didn't find a way to get third order derivates out of comsol which i needed for the actual force and on the other hand i prefer writing such kind of simulations in c++ using gsl and other libs and get more control over whats going on. When investigations goes further into some none-classic stuff we are lost with a comsol solution anyway (i guess). So politics are just using comsol for solving poisson. Thanks for you help!

Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago May 19, 2012, 3:37 a.m. EDT
Hi

to get higher order derivatives, increase the discetization factor (turn on discretization tab from the preferences, it's hidden by default, as all nice goodies for advanced settings, but to be used by advanced users, too ;)

You can only expect stepwise 2nd derivatives with the default 2nd order discretization, and if you mesh is poor COMSOL reverts to linear discretization and you loose also the second derivative locally
But higher discretization order means also more RAM and longer solving. But it works fine (with some local ringing at singularities or step gradients, but that is from the math, so long one knows about it

--
Good luck
Ivar
Hi to get higher order derivatives, increase the discetization factor (turn on discretization tab from the preferences, it's hidden by default, as all nice goodies for advanced settings, but to be used by advanced users, too ;) You can only expect stepwise 2nd derivatives with the default 2nd order discretization, and if you mesh is poor COMSOL reverts to linear discretization and you loose also the second derivative locally But higher discretization order means also more RAM and longer solving. But it works fine (with some local ringing at singularities or step gradients, but that is from the math, so long one knows about it -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jun 5, 2012, 10:45 a.m. EDT
For anybody who may face the same problem:
The suggested mesing method lead to a dramatic increase of accuracy in exported values!

For anybody who may face the same problem: The suggested mesing method lead to a dramatic increase of accuracy in exported values!

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.