PyTOUGH icon indicating copy to clipboard operation
PyTOUGH copied to clipboard

Plot Static 3D Mesh from .dat File

Open pierecnlnd opened this issue 2 years ago • 7 comments

I am seeking to read a .dat file and visualize the mesh static data in actual x, y, and z coordinates. Are there any built-in methods available in PyTough that I can utilize for this purpose?

pierecnlnd avatar Dec 25 '23 05:12 pierecnlnd

Yes, but you will need a mulgrid geometry file for your mesh. Then you can do 2D layer or slice visualization of any quantity using the mulgrid layer_plot() and slice_plot() methods, or export to VTK files for 3D visualization.

acroucher avatar Jan 16 '24 22:01 acroucher

Thank you, sir. Actually, I am still learning to use mulgrid but I already use software like Petrasim to create grid geometry. Is there any methods that you can recommend to convert either from mulgrid to .dat (Petrasim) or vice versa?

pierecnlnd avatar Feb 02 '24 01:02 pierecnlnd

If by ".dat" you mean the TOUGH2 input data file, then PyTOUGH does have methods for converting between .dat and mulgrid. If you have a mulgrid geometry you can use the t2grid.fromgeo() method to create the grid inside the .dat file. If you have a .dat file you can reverse-engineer a mulgrid geometry using the t2grid.rectgeo() method, but only if your grid is rectangular.

acroucher avatar Feb 02 '24 01:02 acroucher

If by ".dat" you mean the TOUGH2 input data file, then PyTOUGH does have methods for converting between .dat and mulgrid. If you have a mulgrid geometry you can use the t2grid.fromgeo() method to create the grid inside the .dat file. If you have a .dat file you can reverse-engineer a mulgrid geometry using the t2grid.rectgeo() method, but only if your grid is rectangular.

Hello dear Adrian,

Can you please give us the full syntax of 't2grid.rectgeo()' ? My TOUGH2 input data file is named INFILE.dat

I tried the following syntax but got errors dat.grid=t2grid().rectgeo(origin_block =None, atmos_volume =1.e25, remove_inactive =True, atmos_type =2, justify ='r',spaces =True, layer_snap =0.1, block_order =None,convention = 2, chars = ascii_lowercase + ascii_uppercase)

medhay36 avatar Feb 02 '24 08:02 medhay36

That syntax looks ok. The obvious thing that can go wrong with rectgeo() is that the grid is not actually rectangular (e.g. it has areas of local refinement). What kind of errors did you get?

acroucher avatar Feb 07 '24 22:02 acroucher

That syntax looks ok. The obvious thing that can go wrong with rectgeo() is that the grid is not actually rectangular (e.g. it has areas of local refinement). What kind of errors did you get?

Hello Adrian,

this is the most revealant error i encounter

ValueError: All-NaN slice encountered

image

medhay36 avatar Feb 08 '24 07:02 medhay36

It looks like maybe your input file doesn't have block centres in the grid? You will definitely need those before you can make a geometry from it.

acroucher avatar Feb 08 '24 22:02 acroucher