Re: [Gmsh] Post-processing stress field

2019-01-31 Thread Christophe Geuzaine


> On 31 Jan 2019, at 10:26, Alessandro Vicini  
> wrote:
> 
> 
> Great, thank you. Could you clarify what are the 9 values that you associate 
> with the element and with each node?

the 9 tensor components, per row

> 
> A.
> 
> 
> -Messaggio originale-
> Da: Christophe Geuzaine [mailto:cgeuza...@uliege.be] 
> Inviato: giovedì 31 gennaio 2019 09:46
> A: Alessandro Vicini
> Cc: gmsh@onelab.info
> Oggetto: Re: [Gmsh] Post-processing stress field
> 
> 
> 
>> On 31 Jan 2019, at 09:40, Alessandro Vicini  
>> wrote:
>> 
>> 
>> I would be grateful if you could post a similar MSH2 example for a 
>> tetrahedron grid, with 1 data field assigned on nodes and another one 
>> assigned on cell centers...
>> 
> 
> Here we go:
> 
> $MeshFormat
> 2.0 0 8
> $EndMeshFormat
> $Nodes
> 4
> 1 0.0 0.0 0.0
> 2 0.1 0.0 0.0
> 3 0.1 0.1 0.0
> 4 0.0 0.0 0.1
> $EndNodes
> $Elements
> 1
> 1000 4  2 6 100  1 2 3 4
> $EndElements
> $ElementData
> 1
> "stress field per element"
> 1
> 0.
> 3
> 0
> 9
> 1
> 1000  1 0 0 0 2 0 0 0 3
> $EndElementData
> $NodeData
> 1
> "stress field per node"
> 1
> 0.
> 3
> 0
> 9
> 4
> 1  1 0 0 0 2 0 0 0 3
> 2  1 0.1 0.1 0.1 2 0.1 0.1 0.1 3
> 3  1 0.2 0.2 0.2 2 0.2 0.2 0.2 3
> 4  1 0.3 0.3 0.3 2 0.3 0.3 0.3 3
> $EndNodeData
> 
> 
> 
>> A.
>> 
>> 
>> -Messaggio originale-
>> Da: gmsh [mailto:gmsh-boun...@ace20.montefiore.ulg.ac.be] Per conto di 
>> Christophe Geuzaine
>> Inviato: giovedì 31 gennaio 2019 09:37
>> A: Max Orok
>> Cc: gmsh@onelab.info; Gaetano Camarda
>> Oggetto: Re: [Gmsh] Post-processing stress field
>> 
>> 
>> 
>>> On 30 Jan 2019, at 23:58, Max Orok  wrote:
>>> 
>>> Yes, the stresses belong in the $ElementData section for sure. 
>>> I think to correctly display it, you'll need to create rows of element data 
>>> with 10 entries - 1 for the element number and 9 for the stress tensor 
>>> values:
>>> 
>>> 1 sigx sigxy sigxz sigxy sigy sigyz sigxz sigyz sigz
>>> 
>>> I don't know if copying and pasting this pattern in ElementData will work 
>>> without some tweaks...
>> 
>> That's correct. Here is a simple MSH2 example with 2 quads, with values [1 0 
>> 0, 2 0 0, 3 0 0] and [1 0.1 0.1, 0.1 2 0.1, 0.1 0.1 3]:
>> 
>> $MeshFormat
>> 2.0 0 8
>> $EndMeshFormat
>> $Nodes
>> 6
>> 1 0.0 0.0 0.0
>> 2 0.1 0.0 0.0
>> 3 0.1 0.3 0.0
>> 4 0.0 0.3 0.0
>> 5 0.0 0.15 0.0
>> 6 0.1 0.15 0.0
>> $EndNodes
>> $Elements
>> 2
>> 1000 3  2 6 100  1 2 6 5
>> 1001 3  2 6 100  5 6 3 4
>> $EndElements
>> $ElementData
>> 1
>> "stress field per element"
>> 1
>> 0.
>> 3
>> 0
>> 9
>> 2
>> 1000  1 0 0 0 2 0 0 0 3
>> 1001  1 0.1 0.1 0.1 2 0.1 0.1 0.1 3
>> $EndElementData
>> 
>> PS: the next release will improve the computation of the min/max for 
>> tensor fields. (Currently the min/max is computed using the default 
>> representation for tensors, i.e. Von-Mises. The next release will take 
>> the tensor visualization mode into account when explicitly requesting 
>> the calculation of min/max.)
>> 
>> Christophe
>> 
>> 
>>> (there is an InterpolationScheme section that I don't quite understand). If 
>>> it were me, I would add the data using the gmsh API and it will handle the 
>>> output format how it likes. 
>>> 
>>> Sincerely,
>>> Max
>>> 
>>> 
>>> On Wed, Jan 30, 2019 at 2:42 PM Gaetano Camarda  wrote:
>>> Thanks for your help, but I think I have not understood well. 
>>> I have a mesh all brick (8 nodes) and my stress field matrix is composed 
>>> this way:
>>> 1 sigx sigy sigz sigxy sigyz sigxz
>>>  ... .....
>>> 
>>> In each row is express the stress state of the element, I think I have to 
>>> copy this matrix into .msh file as $ElementData, but I do not unsterstand 
>>> well the input format, is that right this way? 
>>> 
>>> 
>>> Outlook per iOS
>>> Da: Max Orok 
>>> Inviato: martedì, gennaio 29, 2019 7:14 PM
>>> A: Gaetano Camarda
>>> Cc: gmsh@onelab.info
>>> Oggetto: Re: [Gmsh] Post-processing stress field
>>> 
>>> Hello Gaetano,
>>> 
>>> Here is a short program to plot 3x3 tensor data using the C++ gms

Re: [Gmsh] Post-processing stress field

2019-01-31 Thread Christophe Geuzaine


> On 31 Jan 2019, at 09:40, Alessandro Vicini  
> wrote:
> 
> 
> I would be grateful if you could post a similar MSH2 example for a 
> tetrahedron grid, with 1 data field assigned on nodes and another one 
> assigned on cell centers...
> 

Here we go:

$MeshFormat
2.0 0 8
$EndMeshFormat
$Nodes
4
1 0.0 0.0 0.0
2 0.1 0.0 0.0
3 0.1 0.1 0.0
4 0.0 0.0 0.1
$EndNodes
$Elements
1
1000 4  2 6 100  1 2 3 4
$EndElements
$ElementData
1
"stress field per element"
1
0.
3
0
9
1
1000  1 0 0 0 2 0 0 0 3
$EndElementData
$NodeData
1
"stress field per node"
1
0.
3
0
9
4
1  1 0 0 0 2 0 0 0 3
2  1 0.1 0.1 0.1 2 0.1 0.1 0.1 3
3  1 0.2 0.2 0.2 2 0.2 0.2 0.2 3
4  1 0.3 0.3 0.3 2 0.3 0.3 0.3 3
$EndNodeData



> A.
> 
> 
> -Messaggio originale-
> Da: gmsh [mailto:gmsh-boun...@ace20.montefiore.ulg.ac.be] Per conto di 
> Christophe Geuzaine
> Inviato: giovedì 31 gennaio 2019 09:37
> A: Max Orok
> Cc: gmsh@onelab.info; Gaetano Camarda
> Oggetto: Re: [Gmsh] Post-processing stress field
> 
> 
> 
>> On 30 Jan 2019, at 23:58, Max Orok  wrote:
>> 
>> Yes, the stresses belong in the $ElementData section for sure. 
>> I think to correctly display it, you'll need to create rows of element data 
>> with 10 entries - 1 for the element number and 9 for the stress tensor 
>> values:
>> 
>> 1 sigx sigxy sigxz sigxy sigy sigyz sigxz sigyz sigz
>> 
>> I don't know if copying and pasting this pattern in ElementData will work 
>> without some tweaks...
> 
> That's correct. Here is a simple MSH2 example with 2 quads, with values [1 0 
> 0, 2 0 0, 3 0 0] and [1 0.1 0.1, 0.1 2 0.1, 0.1 0.1 3]:
> 
> $MeshFormat
> 2.0 0 8
> $EndMeshFormat
> $Nodes
> 6
> 1 0.0 0.0 0.0
> 2 0.1 0.0 0.0
> 3 0.1 0.3 0.0
> 4 0.0 0.3 0.0
> 5 0.0 0.15 0.0
> 6 0.1 0.15 0.0
> $EndNodes
> $Elements
> 2
> 1000 3  2 6 100  1 2 6 5
> 1001 3  2 6 100  5 6 3 4
> $EndElements
> $ElementData
> 1
> "stress field per element"
> 1
> 0.
> 3
> 0
> 9
> 2
> 1000  1 0 0 0 2 0 0 0 3
> 1001  1 0.1 0.1 0.1 2 0.1 0.1 0.1 3
> $EndElementData
> 
> PS: the next release will improve the computation of the min/max for tensor 
> fields. (Currently the min/max is computed using the default representation 
> for tensors, i.e. Von-Mises. The next release will take the tensor 
> visualization mode into account when explicitly requesting the calculation of 
> min/max.)
> 
> Christophe
> 
> 
>> (there is an InterpolationScheme section that I don't quite understand). If 
>> it were me, I would add the data using the gmsh API and it will handle the 
>> output format how it likes. 
>> 
>> Sincerely,
>> Max
>> 
>> 
>> On Wed, Jan 30, 2019 at 2:42 PM Gaetano Camarda  wrote:
>> Thanks for your help, but I think I have not understood well. 
>> I have a mesh all brick (8 nodes) and my stress field matrix is composed 
>> this way:
>> 1 sigx sigy sigz sigxy sigyz sigxz
>>   ... ........    .....
>> 
>> In each row is express the stress state of the element, I think I have to 
>> copy this matrix into .msh file as $ElementData, but I do not unsterstand 
>> well the input format, is that right this way? 
>> 
>> 
>> Outlook per iOS
>> Da: Max Orok 
>> Inviato: martedì, gennaio 29, 2019 7:14 PM
>> A: Gaetano Camarda
>> Cc: gmsh@onelab.info
>> Oggetto: Re: [Gmsh] Post-processing stress field
>> 
>> Hello Gaetano,
>> 
>> Here is a short program to plot 3x3 tensor data using the C++ gmsh API (it 
>> shouldn't be too hard to port to Python or Julia if you're more comfortable 
>> there). It only plots data for one element, but can be extended for your 
>> case.
>> 
>> The "addModelData" call is expecting a vector of vectors with 9 entries each 
>> for this case.
>> I think the vector ordering corresponding to the matrix is like this: 
>> [elt11, elt12, elt13, elt21, elt22, ...]
>> 
>> I assume the stress matrix is symmetric and so only has 6 unique entries.
>> Therefore your vector entries will look like [x xy xz xy y yz xz yz z] 
>> The tricky part will be importing the data in a sensible way.
>> 
>> Perhaps you could parse a CSV using python and add entries to the data 
>> vector in a loop?
>> Please find attached the program as well as example input mesh and output 
>> mesh files.
>> 
>> 
>> 
>> 
>> 
>> Sincerely,
>> Max
>> 
>> On Tue, Jan 29, 2019 at 11:24 AM Gaetano Camarda  wrote:
>> Hello everyone,
>> 
>> I’m having some difficult on post process

Re: [Gmsh] Post-processing stress field

2019-01-31 Thread Christophe Geuzaine


> On 30 Jan 2019, at 23:58, Max Orok  wrote:
> 
> Yes, the stresses belong in the $ElementData section for sure. 
> I think to correctly display it, you'll need to create rows of element data 
> with 10 entries - 1 for the element number and 9 for the stress tensor values:
> 
> 1 sigx sigxy sigxz sigxy sigy sigyz sigxz sigyz sigz 
> 
> I don't know if copying and pasting this pattern in ElementData will work 
> without some tweaks...

That's correct. Here is a simple MSH2 example with 2 quads, with values [1 0 0, 
2 0 0, 3 0 0] and [1 0.1 0.1, 0.1 2 0.1, 0.1 0.1 3]:

$MeshFormat
2.0 0 8
$EndMeshFormat
$Nodes
6
1 0.0 0.0 0.0
2 0.1 0.0 0.0
3 0.1 0.3 0.0
4 0.0 0.3 0.0
5 0.0 0.15 0.0
6 0.1 0.15 0.0
$EndNodes
$Elements
2
1000 3  2 6 100  1 2 6 5
1001 3  2 6 100  5 6 3 4
$EndElements
$ElementData
1
"stress field per element"
1
0.
3
0
9
2
1000  1 0 0 0 2 0 0 0 3
1001  1 0.1 0.1 0.1 2 0.1 0.1 0.1 3
$EndElementData

PS: the next release will improve the computation of the min/max for tensor 
fields. (Currently the min/max is computed using the default representation for 
tensors, i.e. Von-Mises. The next release will take the tensor visualization 
mode into account when explicitly requesting the calculation of min/max.)

Christophe


> (there is an InterpolationScheme section that I don't quite understand). If 
> it were me, I would add the data using the gmsh API and it will handle the 
> output format how it likes. 
> 
> Sincerely,
> Max
> 
> 
> On Wed, Jan 30, 2019 at 2:42 PM Gaetano Camarda  wrote:
> Thanks for your help, but I think I have not understood well. 
> I have a mesh all brick (8 nodes) and my stress field matrix is composed this 
> way:
> 1 sigx sigy sigz sigxy sigyz sigxz
>... .....
> 
> In each row is express the stress state of the element, I think I have to 
> copy this matrix into .msh file as $ElementData, but I do not unsterstand 
> well the input format, is that right this way? 
> 
> 
> Outlook per iOS
> Da: Max Orok 
> Inviato: martedì, gennaio 29, 2019 7:14 PM
> A: Gaetano Camarda
> Cc: gmsh@onelab.info
> Oggetto: Re: [Gmsh] Post-processing stress field
>  
> Hello Gaetano, 
> 
> Here is a short program to plot 3x3 tensor data using the C++ gmsh API (it 
> shouldn't be too hard to port to Python or Julia if you're more comfortable 
> there). It only plots data for one element, but can be extended for your case.
> 
> The "addModelData" call is expecting a vector of vectors with 9 entries each 
> for this case.
> I think the vector ordering corresponding to the matrix is like this: 
> [elt11, elt12, elt13, elt21, elt22, ...] 
> 
> I assume the stress matrix is symmetric and so only has 6 unique entries.
> Therefore your vector entries will look like [x xy xz xy y yz xz yz z]
> The tricky part will be importing the data in a sensible way.  
> 
> Perhaps you could parse a CSV using python and add entries to the data vector 
> in a loop?
> Please find attached the program as well as example input mesh and output 
> mesh files.
> 
> 
> 
> 
> 
> Sincerely,
> Max
> 
> On Tue, Jan 29, 2019 at 11:24 AM Gaetano Camarda  wrote:
> Hello everyone,
> 
> I’m having some difficult on post processing a mesh I created.
> 
> I create a mesh on Gmsh all Hexa (so a brick with 8 nodes), i use this mesh 
> and import it on Matlab,
> 
> there i run some analisys and find the stress matrix:
> 
> [sigx sigy sigz sigxy sigyz sigxz]
> 
> …..…..…..   …..…..…..
> 
>  
> 
> Now I would like to visualize the stress field on Gmsh, but I do not find any 
> way to do so, I can export the matrix,
> 
> I tried to generete a *.pos file, but I didn’t find a solution.
> 
>  
> 
> Inviato da Posta per Windows 10
> 
>  
> 
> ___
> gmsh mailing list
> gmsh@onelab.info
> http://onelab.info/mailman/listinfo/gmsh
> 
> 
> -- 
> Max Orok
> Contractor
> www.mevex.com
> 
> 
> 
> 
> -- 
> Max Orok
> Contractor
> www.mevex.com
> 
> 
> ___
> gmsh mailing list
> gmsh@onelab.info
> http://onelab.info/mailman/listinfo/gmsh

— 
Prof. Christophe Geuzaine
University of Liege, Electrical Engineering and Computer Science 
http://www.montefiore.ulg.ac.be/~geuzaine




___
gmsh mailing list
gmsh@onelab.info
http://onelab.info/mailman/listinfo/gmsh


Re: [Gmsh] Post-processing stress field

2019-01-30 Thread Max Orok
Yes, the stresses belong in the $ElementData section for sure.
I think to correctly display it, you'll need to create rows of element data
with 10 entries - 1 for the element number and 9 for the stress tensor
values:

1 sigx sigxy sigxz sigxy sigy sigyz sigxz sigyz sigz

I don't know if copying and pasting this pattern in ElementData will work
without some tweaks... (there is an InterpolationScheme section that I
don't quite understand). If it were me, I would add the data using the gmsh
API and it will handle the output format how it likes.

Sincerely,
Max


On Wed, Jan 30, 2019 at 2:42 PM Gaetano Camarda  wrote:

> Thanks for your help, but I think I have not understood well.
> I have a mesh all brick (8 nodes) and my stress field matrix is composed
> this way:
> 1 sigx sigy sigz sigxy sigyz sigxz
>... .....
>
> In each row is express the stress state of the element, I think I have to
> copy this matrix into .msh file as $ElementData, but I do not unsterstand
> well the input format, is that right this way?
>
>
> Outlook <https://aka.ms/qtex0l> per iOS
> --
> *Da:* Max Orok 
> *Inviato:* martedì, gennaio 29, 2019 7:14 PM
> *A:* Gaetano Camarda
> *Cc:* gmsh@onelab.info
> *Oggetto:* Re: [Gmsh] Post-processing stress field
>
> Hello Gaetano,
>
> Here is a short program to plot 3x3 tensor data using the C++ gmsh API (it
> shouldn't be too hard to port to Python or Julia if you're more comfortable
> there). It only plots data for one element, but can be extended for your
> case.
>
> The "addModelData" call is expecting a vector of vectors with 9 entries
> each for this case.
> I think the vector ordering corresponding to the matrix is like this:
> [elt11, elt12, elt13, elt21, elt22, ...]
>
> I assume the stress matrix is symmetric and so only has 6 unique entries.
> Therefore your vector entries will look like [x xy xz xy y yz xz yz z]
> The tricky part will be importing the data in a sensible way.
>
> Perhaps you could parse a CSV using python and add entries to the data
> vector in a loop?
> Please find attached the program as well as example input mesh and output
> mesh files.
>
>
>
> [image: image.png]
>
> Sincerely,
> Max
>
> On Tue, Jan 29, 2019 at 11:24 AM Gaetano Camarda 
> wrote:
>
>> Hello everyone,
>>
>> I’m having some difficult on post processing a mesh I created.
>>
>> I create a mesh on Gmsh all Hexa (so a brick with 8 nodes), i use this
>> mesh and import it on Matlab,
>>
>> there i run some analisys and find the stress matrix:
>>
>> [sigx sigy sigz sigxy sigyz sigxz]
>>
>> …..…..…..   …..…..…..
>>
>>
>>
>> Now I would like to visualize the stress field on Gmsh, but I do not find
>> any way to do so, I can export the matrix,
>>
>> I tried to generete a *.pos file, but I didn’t find a solution.
>>
>>
>>
>> Inviato da Posta
>> <https://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgo.microsoft.com%2Ffwlink%2F%3FLinkId%3D550986=02%7C01%7C%7Cca31cd7089a2464649bc08d68615abee%7C84df9e7fe9f640afb435%7C1%7C0%7C636843824966724800=B9ULg21XHyAFBAd6yWI8Wsc%2B9fTHxhibsTu5e1UtiUM%3D=0>
>> per Windows 10
>>
>>
>> ___
>> gmsh mailing list
>> gmsh@onelab.info
>> http://onelab.info/mailman/listinfo/gmsh
>> <https://eur04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fonelab.info%2Fmailman%2Flistinfo%2Fgmsh=02%7C01%7C%7Cca31cd7089a2464649bc08d68615abee%7C84df9e7fe9f640afb435%7C1%7C0%7C636843824966734804=x5CcVoLrp3YNu69ZWMj3fvkDM1zD5CNYD4soeJ25tfo%3D=0>
>>
>
>
> --
> Max Orok
> Contractor
> www.mevex.com
> <https://eur04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.mevex.com=02%7C01%7C%7Cca31cd7089a2464649bc08d68615abee%7C84df9e7fe9f640afb435%7C1%7C0%7C636843824966734804=9Qnyosr1z%2BWkN%2FpOeuE8LZewBbv0q0WUfPa92IL3m9M%3D=0>
>
>
>

-- 
Max Orok
Contractor
www.mevex.com
___
gmsh mailing list
gmsh@onelab.info
http://onelab.info/mailman/listinfo/gmsh


Re: [Gmsh] Post-processing stress field

2019-01-29 Thread Max Orok
Hello Gaetano,

Here is a short program to plot 3x3 tensor data using the C++ gmsh API (it
shouldn't be too hard to port to Python or Julia if you're more comfortable
there). It only plots data for one element, but can be extended for your
case.

The "addModelData" call is expecting a vector of vectors with 9 entries
each for this case.
I think the vector ordering corresponding to the matrix is like this:
[elt11, elt12, elt13, elt21, elt22, ...]

I assume the stress matrix is symmetric and so only has 6 unique entries.
Therefore your vector entries will look like [x xy xz xy y yz xz yz z]
The tricky part will be importing the data in a sensible way.

Perhaps you could parse a CSV using python and add entries to the data
vector in a loop?
Please find attached the program as well as example input mesh and output
mesh files.



[image: image.png]

Sincerely,
Max

On Tue, Jan 29, 2019 at 11:24 AM Gaetano Camarda  wrote:

> Hello everyone,
>
> I’m having some difficult on post processing a mesh I created.
>
> I create a mesh on Gmsh all Hexa (so a brick with 8 nodes), i use this
> mesh and import it on Matlab,
>
> there i run some analisys and find the stress matrix:
>
> [sigx sigy sigz sigxy sigyz sigxz]
>
> …..…..…..   …..…..…..
>
>
>
> Now I would like to visualize the stress field on Gmsh, but I do not find
> any way to do so, I can export the matrix,
>
> I tried to generete a *.pos file, but I didn’t find a solution.
>
>
>
> Inviato da Posta  per
> Windows 10
>
>
> ___
> gmsh mailing list
> gmsh@onelab.info
> http://onelab.info/mailman/listinfo/gmsh
>


-- 
Max Orok
Contractor
www.mevex.com
// Jan 29 MXO

// example to plot 3x3 tensor data using gmsh API

#include 
#include 
#include "gmsh.h"

int main(){

// step 1 of 2 -> import data for plotting (need the mesh and the simulation 
data)

  gmsh::initialize();

  // open mesh file to use as reference for plotting
  // we will write our results to another mesh file for output
  gmsh::open("model.msh");

  // tell gmsh what elements of the mesh we want to plot data for
  std::vector elt_numbers;
  // only plot data for element 1 for simplicity
  elt_numbers.emplace_back(1);

  // fill a data vector corresponding to the element vector
  // the data vector's elements are vectors of length 9 (3x3 tensor)
  std::vector> elt_data;

///

  // this is the tricky part -> how to import data in an intelligent way?
  // here we make a single zero vector of length 9 for demonstration
  elt_data.emplace_back(std::vector(9, 0.0));

///

// step 2 of 2 -> ask Gmsh API to plot the data (see gmsh.h for reference)

  //get model name
  std::vector modelNames;
  gmsh::model::list(modelNames);
  auto modelName = modelNames[0];

  auto viewTag = gmsh::view::add("stress-data");

  gmsh::view::addModelData(viewTag, 0, modelName,
"ElementData", elt_numbers, elt_data, 0.);

  //toggle here to see behaviour
  gmsh::view::write(viewTag, "stress-data.msh");

  //end gmsh run
  gmsh::finalize();
  return 0;
}


model.msh
Description: Binary data


stress-data.msh
Description: Binary data
___
gmsh mailing list
gmsh@onelab.info
http://onelab.info/mailman/listinfo/gmsh