acroucher / PyTOUGH

A Python library for automating TOUGH2 simulations of subsurface fluid and heat flow
GNU Lesser General Public License v3.0
96 stars 36 forks source link

VTK export from TOUGHREACT #46

Closed nikolai-andrianov closed 1 year ago

nikolai-andrianov commented 1 year ago

Thanks for pyTOUGH, has been quite useful!

The write_vtk method of toughreact_tecplot yields an error when exporting TOUGHREACT simulation results to VTK in get_vtk_data around line 1804 of t2listing.py. Apparently this happens when geo_matches == False in this subroutine which is always the case due to the comparison

geo_matches = geo.block_name_list == self.element.row_name

in write_vtk (which always gives False because a list is compared to a dict).

A workaround is to replace this comparison by

geo_matches = geo.block_name_list == list(self.element.row_name.keys())
acroucher commented 1 year ago

The self.element.row_name variable should be of type list, not dict.

Is it possible you are passing in a dict for the blocks parameter when you create your toughreact_tecplot object?

The blocks parameter should be either a list, a mulgrid or a t2grid. A dict can't be used because the order of the block names is important.

nikolai-andrianov commented 1 year ago

The toughreact_tecplot object is created from dat.grid.block, which is in turn created by calling the t2grid() constructor. So when I call write_vtk method of toughreact_tecplot, self.element.row_name is a dict, not list. See an example script tough_cpg.py at https://github.com/nikolai-andrianov/TOUGH-CPG.

acroucher commented 1 year ago

You should just pass in dat.grid for the blocks parameter, not dat.grid.block. As the user guide says, this parameter should be either a list of strings, a mulgrid geometry object or a t2grid object.

For example, line 469 in your script should be:

lst = toughreact_tecplot(folder + '/flowdata.tec', dat.grid)
nikolai-andrianov commented 1 year ago

That works, thanks a lot!