Giter Club home page Giter Club logo

mtex2gmsh's Introduction

MTEX2Gmsh DOI View MTEX2Gmsh on File Exchange License: MIT

This toolbox for Matlab allows to generate meshes from EBSD data. It is intended to perform Finite Element Analysis (FEA) at grain scale on polycrystal imaged by EBSD. It is based on MTEX and Gmsh.

๐Ÿค” How it works

This toolbox defines the class named gmshGeo. Once the grains are computed using MTEX, an instance of gmshGeo can be constructed. This object can be used to generate a Gmsh-readable file, in order to mesh it and perform FEA.

๐Ÿ‘ท Requirements

This toolbox has been designed for MATLAB R2013b, but it may work on newer versions. In addition, the following are required:

  • The MTEX toolbox (v 5.3.1 or newer) should be installed in your MATLAB session;
  • The Gmsh software (v 4.9.5 or newer) should be installed on your computer (at least its binary should accessible).

It works on both Windows and Unix-like plateform (Linux and Mac OS).

๐Ÿง Linux users When running the ``mesh`` command, you may stumble on the error below:
/MATLAB/sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by gmsh)

If so, instead of running

matlab

run

LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libstdc++.so.6" matlab

๐Ÿ” Documentation and examples

Here is an example of mesh obtained from the EBSD map called aachen in MTEX: aachen example

Visit the corresponding site to see other examples and full documentation. Alternatively, you can check out the docs/Examples folder.

โš™๏ธ Unit test

The aforementioned examples can be easily reproduced. In addition, the reader can check out the reproductibility of minimal example on Code Ocean.

๐Ÿ˜Ž Graphical User Interface

If you don't have time to read the documentation, check out the Graphical User Interface (GUI) by running:

MTEX2GmshGUI

It will open a dialog box gathering all the parameters available in MTEX2Gmsh in a more user-friendly way.

๐Ÿ“š Reference

If you use this work, please cite the following paper:

Depriester et al., (2020). MTEX2Gmsh: a tool for generating 2D meshes from EBSD data. Journal of Open Source Software, 5(52), 2094, https://doi.org/10.21105/joss.02094

In BibTeX, use the following entry:

@article{MTEX2Gmsh,
  doi = {10.21105/joss.02094},
  url = {https://doi.org/10.21105/joss.02094},
  year = {2020},
  publisher = {The Open Journal},
  volume = {5},
  number = {52},
  pages = {2094},
  author = {Dorian Depriester and R\'egis Kubler},
  title = {{MTEX2Gmsh}: a tool for generating {2D} meshes from {EBSD} data},
  journal = {Journal of Open Source Software}
}

๐Ÿš‘ Bug report

Please, use the Issue tab to report any bug or whish for new feature.

๐Ÿค Contribute

You can easily edit the present code so that it fits your needs (as long as this edit complies with the MIT licence). You are also welcome to contribute. In this case, please read CONTRIBUTING.md.

mtex2gmsh's People

Contributors

doriandepriester avatar ralfhielscher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

mtex2gmsh's Issues

Documentation

I have a few suggestions to improve documentation per openjournals/joss-reviews#2094

Concerning the tutorial:

  • Specify matlab, mtex, and gmsh versions required (potentially gcc underlying gmsh)
  • Data initialization should have a heading and code block formatting (currently only done for the "Improve" section), ideally pointing out this examples from mtex are being used
  • Link to doc page in README (maybe add image)
  • In the "Mesh" and "Customize" sections the figures are not directly from code examples - either be very clear about this or add how to obtain these images as part of the tutorial

The example cases are easy to follow and seem to cover the extent of the intended uses, but unit testing is missing. Some recently accepted joss papers using matlab have what seems to be an offline-automated test suite

  • Add unit tests

I did not see any API documentation (maybe I am forgetting how to access this in matlab)

  • Add API docs

Finally, make sure to add a CONTRIBUTING.md file for Github contributors

  • CONTRIBUTING.md

how to plot the output from Quadrature file.

Dear Dorian,

Thank you for creating such a nice toolbox. I created the gmsh and orientation file for input using the MTEX2Gmsh toolbox.

I ran some simulations. The output is the Quadrature file. I have now the x, yz, r_x,r_y and r_z as output. I wish to plot it.

(1) Is there any possibility of plotting it directly or I have to convert it to Bunge angles first.
(2) I suppose its unstructured mesh. So I should use paraview or some other software.

Regards
Rajesh

Physical Surface when meshing in 2D

Hi Dorian,

Very nice toolbox! Thanks for sharing.

When using savegeo() to create a GMSH geometry file like as follows:

savegeo(G,strcat(output,'.geo'),'ElementSize',elt_size,'gradient',gradient,'ElementType','Tri');

The .geo file contains lines to create Physical Volumes (just below // Sets), although the given options will result in a 2D mesh.
Would it make sense to replace "Physical Volume" by "Physical Surface" when 2D mesh options are passed as arguments to the savegeo function ?

Regards

Jean-Michel

Paper revisions

  • The paper may be more accessible to a general (materials science) audience if the first two sentences are flipped: grain morphology and texture are greatly important for materials behavior, and micromechanics is of great use to that end.
  • In paragraph 2 please note these are experimental techniques
  • Are you limited to a subset of phases based on implementation, or is it generalized? More specifically, you mention a cubic "criterion", but I do not understand the extension to the current work.
  • As I understand, your work builds on the previous by expanding to (contingent on the previous question) any phases/orientations by combining the two underlying codes - please make this explicit
  • Within the figure caption you recite mtex, but not gmsh

openjournals/joss-reviews#2094

Paper review

Hi Dorian,

I went through the code and found it very useful and impressive. I think there are some places for improvement.
I will list them here but I don't think that they are showstopper for the review process.

  1. A central point seems to be the reordering of the boundary segments . Here you use an algorithm based on Euler Tours. MTEX itself contains already some Euler Tour algorithms in mtex/tools/graph_tools which might be more efficient. Another idea can be found in the last paragraph of grain2d/subSet. Here the boundary segments are ordered without the use of any Euler Tours command by making use of the fact that grain2d.poly contains already a ordered list of vertices.

  2. For me it would make a lot of sense to include the ordering directly into MTEX. Currently, the grainboundary segments are not ordered at all (unless there is only a single grains). The ordering you suggest seems very reasonable and could easily be the default ordering in MTEX.

  3. The spline interpolation seems to be used only for plotting. This is not so clear from the documentation. Also, wouldn't it make more sense to use some buildin spline function like spline instead of a custom one.

  4. Smoothing the boundary while keeping triple points and points at the outer boundary fixed should actually be an option within MTEX :) Same is true for the simplification of the geometry,

  5. When publishing the help files it is useful to set

setMTEXpref('generatingHelpMode',true);

as it avoids some output artifacts.

  1. I'm not completely convinced about having an extra class for the grains. Wouldn't it make more sense to inherit from grain2d? When I understood this correctly the main difference to the class grain2d is that the boundary segments are sorted and the gmshGeo keeps track of this order. I'm correct?

[need some help] mesh-command fails

Hello Dorian,
maybe it is more a problem of python or gmsh, but the mesh-command of MTEX2Gmsh fails - any idea of what I'm doing wrong?
Thanks
Stefan

mesh(G,'small.inp');
Info : Running 'C:\gmsh480\gmsh.exe C:\Users\Stefa\AppData\Local\Temp\tpf2ba8dd2_169d_42f7_a970_0dcbd065c0e3 -o small.inp -v 4 -save' [Gmsh 4.8.0, 1 node, max. 1 thread]
Info : Started on Tue Apr 06 20:08:11 2021
Info : Reading 'C:\Users\Stefa\AppData\Local\Temp\tpf2ba8dd2_169d_42f7_a970_0dcbd065c0e3'...
Info : Writing 'small.inp'...
Info : Done writing 'small.inp'
Info : Shell opening 'C:\Users\Stefa\gmsh-4.8.0-Windows64\tutorial\python\t1.py' with arguments ' -onelab "t1" 127.0.0.1:51647'
Error : Abnormal server termination (Socket listening timeout on socket 127.0.0.1:0)
Info : Shell opening 'C:\Users\Stefa\gmsh-4.8.0-Windows64\tutorial\python\t1.py' with arguments ' -onelab "t1" 127.0.0.1:51648'
Error : Abnormal server termination (Socket listening timeout on socket 127.0.0.1:0)
Info : Shell opening 'C:\Users\Stefa\gmsh-4.8.0-Windows64\tutorial\python\t1.py' with arguments ' -onelab "t1" 127.0.0.1:51650'
Error : Abnormal server termination (Socket listening timeout on socket 127.0.0.1:0)
Info : Saving database 'C:\Users\Stefa\AppData\Local\Temp\tpf2ba8dd2_169d_42f7_a970_0dcbd065c0e3.db'...
Info : Done saving database 'C:\Users\Stefa\AppData\Local\Temp\tpf2ba8dd2_169d_42f7_a970_0dcbd065c0e3.db'
Info : Stopped on Tue Apr 06 20:08:26 2021 (From start: Wall 15.1449s, CPU 0.03125s)

Gradient option does not work in 2D

          Thank you very much for your responses. I clearly missed this in the documentation upon a second read-through.

I do have an additional question regarding the 2D mesh. In 3D, the "gradient" command is working perfectly and successfully meshing in ABAQUS when I create and upload the .inp file. However, when I use any of the available 2D element options along with the gradient command, the gradient effect is overlooked when the mesh is created. All elements are the same size. I also have tried creating the command using the GUI, and see the same result.

The command I used most recently is as follows for the object "G":

mesh(G,'sample.msh','ElementType','Tri','ElementSize',1,'gradient',0.5)

I see this same effect (no gradient) for 'Quad' and 'QuadOnly' 2D options as well. When I upload the .inp file from any 2D mesh into ABAQUS, I then get errors (negative or zero element area) when I check the mesh quality. This is interesting because as I said, things work very well in 3D with all other parameters held equal.

Do you also experience this result when combining the gradient and 2D elements? I would be happy to share the EBSD data I am experimenting with.

Thank you again for your responses.

Originally posted by @Colin-Williams94843 in #17 (comment)

quality of the mesh

Hi Dorian,

Do you have any recommendations on the acceptable mesh quality for Prism-plasticity. Any rule of thumb on the "threshold" values of SICN, Gamma, and SIGE? How good is good enough?

Many thanks,

Diego

Create more elements in Z direction

Hello Dorian,

For the standard command it says: The above command results in a 1 element thick mesh
so i was wondering if there is there a way to apply thickness and have more elements in Z direction?

Thank you
Regards

David.

[help wanted] Creating phase groups

Hi Dorian,

I'm not that confident with GMSH but I added a little something to your mesh command in order to create a group for phases in the fashion you introduced grains groups. This is useful for affecting mechanical behaviors afterwards.

groupPrefix='Gr';
phaseList = unique(obj.Grains.Phase);
for i=1:size(phaseList,1)
Ids = obj.Grains.GrainID(ismember(obj.Grains.Phase,phaseList(i)));
Ids_str = [sprintf('%d,', Ids(1:end-1)), sprintf('%d', Ids(end))];
fprintf(ffid,['Physical Volume("%s_%s")={' Ids_str '};\n'],groupPrefix,phaseList{i,1});
end

I added this piece of code right after you ended the "for" loop in "Physical Volumes" section.
The issue is that GMSH is creating a mesh for grains groups and phase groups resulting in duplicating the elements everywhere (because grain groups are all included in phase groups, lying on the same base geometry entities)

Is there a way to avoid this issue ?

Thanks in advance,

Maxime

medium with an ODF reflecting the bulk texture

Dear Dorian,

I would like to perform Prism-Platicity CPFEM on an EBSD image. To simulate the fact that the area of interest is embed in a polycrystalline medium, I am wondering if the code could generate meshes for an EBSD image and then surround this area of interest with a "buffer layer" comprising grains with each grain represented by a single element. The orientations of these single-element grains in the "buffer layer" are assigned so that they reflect the bulk texture of the material.

Thanks and regards,
Diego

Create edges between nodes in Z direction

i'm working with EBSD data (.CTF) in Mtex and using MTEX2Gmsh

i was wondering if there is a way to create a edge (or line) between front node and back node in order to have nodes along the edge and mesh it to have more element in Z direction insted of just having a big node from front to back?

thank you
Regards
image

Running MTEX2Gmsh on macOS Ventura 13.3.1

Hello!

I am trying to run your toolbox on a Mac. When prompted to identify the executable file for gmsh, I am unable to do so, because the Mac version of gmsh does not use a .exe file.

Are you aware of a workaround to use your toolbox on a Mac?

Thank you,

Colin

Image meshing

Hello,
This tool is very interesting. However, I'd like to know if I can use the tool to mesh images (not necessary coming from EBSD).
It would be helpful if ones can read an image (e.g. imread('')), then mesh it based on colors.
I've an image (attached) and I want to know if I someone can help me to do so.

Thanks

REV_XZ_Filled_300

issues with MTEX2Prisms

Dear Prof. Depriester,

I am trying to use MTEX2prisms to mesh my EBSD data. However, I see a lot of warnings when running the following lines in matlab:

V=grains_Sub_filled.V;
ori = min(V);
grains_Sub_filled.V = V-repmat(ori,size(grains_Sub_filled.V,1),1);
G = gmshGeo(grains_Sub_filled);
G=simplify(G);
max(grains_Sub_filled.V)
mesh(G,'mesh.msh','ElementType','HexOnly','GrainPrefix','','thickness',1);
exportGrainProps(G,'orientations_Ti2.txt','PRISMS')

Warning: wrong control point index in bspline.
Warning: No parametric coordinate on node XXXXX classified on curve XXXXX.

matlab_error message

The generated mesh looks a little weird (see attached figures).

mesh
mesh_magnified view

I run prisms-plasticity using this mesh as an input and it reports "Unable to open eulerDataFile".

prisms_error message

The matlab code and the EBSD file are also attached for your convenience.

I am using matlab R2020a, MTEX 5.7.0 (and 5.5.0), gmsh-4.8.4-Windows64,

Thanks in advance.

Best,

Jie

mesh_EBSD.txt (.m file)
Scan1.txt (.ang file)

Incoherent Elements at grain boundaries

Hi,

Firstly I would like to thank you for the powerful tool that already helped me a lot.

I've recently came across an issue with meshes generated with MTEX2Gmsh. Some grains have inconsistent element at boundaries with their surroundings. I have tried to generate the mesh in gmsh using the .geo file without extrusion, the same problem arises everytime in the same place i.e. if I mesh a small part of my microstructure where the previously incriminated grains is, the same problem persist. Everything seems ok in MTEX though. These grains have no connectivity with the rest of the mesh when performing FEM computations.

I attached a picture illustrating my issue. Have I done something wrong ?
MTEX_issue

Thanks in advance for the help.

EDIT : It seems that there are some wrong spline definitions getting the following gmsh warning "Wrong control point index in bspline"

Maxime

[need some help] gmshGeo fails

Hello Dorian,
Sorry to disturb you. There is a problem when I run the unitTest.m and I haven't modified the code.
My matlab version is R2018b
gmsh 4.12
mtex 5.9.0
I had some try according the Error prompt but it doesn't work. Can you give me some help?
Following is my command window

>> unitTest
 
ebsd = EBSD
 
 Phase  Orientations     Mineral         Color  Symmetry  Crystal reference frame
     0    1197 (32%)  notIndexed                                                 
     1    1952 (52%)  Forsterite  LightSkyBlue       mmm                         
     2    290 (7.8%)   Enstatite  DarkSeaGreen       mmm                         
     3    282 (7.6%)    Diopside     Goldenrod     12/m1       X||a*, Y||b*, Z||c
 
 Properties: bands, bc, bs, error, mad, x, y
 Scan unit : um
 
Error using  * 
Both logical arguments must be scalar. Use TIMES (.*) for elementwise multiplication.

Error in findSingularPoints (line 21)
    I_VG = (I_VF * gB.I_FG)==2;

Error in computeSegments (line 14)
sp=findSingularPoints(grains);

Error in gmshGeo (line 46)
			[Segmts,OuterLoop,InnerLoops,G.SingularPoints]=computeSegments(grains);

Error in unitTest (line 26)
			G=gmshGeo(grains);

Add a 'medium' contour to a 2D mesh

Hi,

The 'medium' option works perfectly in 3D.
I wondered if it also available in 2D, i.e. without extrusion.
I tried by giving a list of only two dimensions, or by setting the last dimension to 0, but without success.

Thanks

Jean-Michel

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.