print parameter

Asked by jamespaul

Hi,

I want to print disp,shear,vR (from https://github.com/yade/trunk/blob/master/examples/FEMxDEM/biaxialSmooth.py#L97) in .dat instead of VTK.

disp = Vector(0.,Solution(mydomain))# I searched Vector() from the document,it construct a Data object containing rank1 data-points,I don't know what is this data type

If I use
>>>print(str(disp))
Summary: inf=-0.0001 sup=4.89781e-05 data points=277

If I use
>>>print(type(disp))
<class 'esys.escriptcore.escriptcpp.Data'>

I can't obtain each data because of the strange data type.I think if I'm going to deal with this data, I'm going to have to know the data type first.

Please give me some ideas, thank you in advance.

Jam

Question information

Language:
English Edit question
Status:
Solved
For:
esys-escript Edit question
Assignee:
No assignee Edit question
Solved by:
Lutz Gross
Solved:
Last query:
Last reply:
Revision history for this message
Lutz Gross (l-gross) said :
#1

I would suggest to use saveDataCSV('output.csv', disp=disp, shear= shear, vR= vR)

Revision history for this message
jamespaul (jamespauljames) said :
#2

Thank you for answering me so soon.I can export the data now.But I still have some things I don't understand.

If I open .vtu in paraview,I can see different color of each cell.So I think each cell has it's numerical value and node coordinate,so it can draw a picture of color gradient.

But in .csv,I can only obtain the numerical value of all the cells.There must be some hidden data.

How can I get each node coordinate or other information.

Revision history for this message
Lutz Gross (l-gross) said :
#3

YOu need to write the coordinates in the csv file, e.g.

saveDataCSV('output.csv', disp=disp, shear= shear, vR= vR, x=disp.getFunctionSpace().getX())

Revision history for this message
jamespaul (jamespauljames) said :
#4

Thanks Lutz Gross.

My script: nx = 4; ny = 4;numg = 4*nx*ny;

Using saveVTK("./result/vtk/biaxialSmooth_%d.vtu"%t,disp=disp,shear=shear,e=vR) ,it will generate two .vtu files(biaxialSmooth_1_Elements.vtu and biaxialSmooth_1_ReducedElements.vtu).I think the reason of generate two instead of one is data on the boundary and on the interior cannot be mixed.

When I opened these in paraview,the picture is different:

1 Elements.vtu shows disp,and the color is gradually varied,number of cells=96,number of points=65
2 ReducedElements.vtu shows shear and vR,and the color is blocky,only 16 block.number of cells=16,number of points=65

My question:
1 Where does 96 come from?
2 I think the elements has been contracted automatically.Is there any method to show all the data in paraview like Elements.vtu?

Best!
Jam

Revision history for this message
jamespaul (jamespauljames) said :
#5
Revision history for this message
jamespaul (jamespauljames) said :
#6

https://imgchr.com/i/AaXefI

This is the picture in others paper.The gradient color is used to output the shear and void ratio.My goal is to generate something like this.

Revision history for this message
Lutz Gross (l-gross) said :
#7

When you use element based data it is one value per cell. This is the reason why the shear and vR is looking blocky.

How did you create the domain incl module?
Thanks

Revision history for this message
jamespaul (jamespauljames) said :
#8

Sorry I can't explain my method.Because I am a new user of FEM.

I use this benchmark (https://github.com/yade/trunk/blob/master/examples/FEMxDEM/biaxialSmooth.py#L97) to reproduce <A coupled fem/dem approach for hierarchical multiscale modelling of granular media. >

My paraview figure is similar to his in general, but mine is blocky and his is smooth.

>This is the reason why the shear and vR is looking blocky.
But why his figure is not blocky. https://imgchr.com/i/AaXefI

Revision history for this message
jamespaul (jamespauljames) said :
#9

>When you use element based data it is one value per cell. This is the reason why the shear and vR is looking blocky.
I used your method to export in csv,and I get 64 data.That is my GP number.
But only16 in vtu.

Revision history for this message
Lutz Gross (l-gross) said :
#10

vtu does allow one value per cell only. Therefore data are averaged over the GP's in the cell.
in the CVS file all 4 GP data are considered hence you have 4 x 16 = 64 values.
I am not sure how these plots have been generated. There is of course the possibility (eg. in paraview) to average values from cells back to nodes. One could also use numpy interpolation for this. There is also a way of do this in escript if you prefer this.

Revision history for this message
jamespaul (jamespauljames) said :
#11

Thank you again.Sorry,it is because of DEM that FEM is understood. I'm a FEM beginner.

>disp.getFunctionSpace().getX()

I think this is the output of the coordinates of the nodes that are displaced.Is mydomain.getX() right ?I am confused about domain and FunctionSpace.
But how can I get the coordinates of the GP and there displacement?

>about export other parameter

I want to export more parameter such as strain,stress,rotation and so on.But I don't think it's right to trouble you every time I can't export parameters.For nodal or GP, I guess there should be a unified method to find out their properties through functions, such as strain,stress and rotation(Just like print material.possion/density/friction).Can you tell me where I can look up these functions? In a document or somewhere.

Revision history for this message
Lutz Gross (l-gross) said :
#12

Well: disp is the displacement and disp.getFunctionSpace().getX() gives you the location where it is calculated.
This is why saveDataCSV('output.csv', disp=disp, x=disp.getFunctionSpace().getX() ) does create a file with the displacement and its location. (You can also create numpy objects directly)

The FunctionSpace is attached to each data object in escript to define where the data are stored (e.g. GP or nodes).
The method mydomain.getX() is something that one should avoid to use as it is ambiguous on what locations we are talking about.

>about export other parameter
You need to understand that escript is not written to solve a specific modelling problem. A concept of strain, stress and rotation are specific for deformation problems which escript as such is not aware of. you can use symmetric(grad(disp)), etc
to get the quantities you want, see eg. https://launchpad.net/escript-finley/3.0+/5.3/+download/doc.zip.
I assume that material.possion is a Yade thing.

Revision history for this message
jamespaul (jamespauljames) said :
#13

>I export shear.getFunctionSpace().getX() and e.getFunctionSpace().getX() to get GP's coordinates.They are GP's data,but I find the coordinates are the same as disp.getFunctionSpace().getX().But the coordinates of nodal and GP cannot be the same.

>vtu does allow one value per cell only. Therefore data are averaged over the GP's in the cell.

I read the run_savevtk_tests.txt.

I think it's something like this that does the average processing of gauss point. But I can't find the division function.
##self.check_vtk("hex_2D_o2_node_3xs", ['Elements','ReducedElements']
Could you tell me which function averages the data because I want to change it.

>I assume that material.possion is a Yade thing.
Yes.My wrong way of thinking is still yade.

Revision history for this message
Best Lutz Gross (l-gross) said :
#14

The first question is a bit difficult to answer as the context in which you look at the coordinates is not clear.
In general I agree with you but if you use the SEM module the coordinates are the same!

The averaging is happening in weipa/src/DataVar.h when data are written to vtu files.
but there are a few other placed. e.g. when 'interpolating' from Elements to ReducedElements.

Revision history for this message
jamespaul (jamespauljames) said :
#15

Thanks Lutz Gross, that solved my question.

Revision history for this message
jamespaul (jamespauljames) said :
#16

Thank you so much !