FireDynamics / fdsreader

Python reader for FDS data
GNU General Public License v3.0
44 stars 18 forks source link

Reading Multi-mesh with different mesh size #61

Closed ShahramKa closed 1 year ago

ShahramKa commented 1 year ago

Hi,

I was wondering if there has been any development on reading multi-mesh with different mesh sizing.

Near the fire having fine mesh and other blocks with coarse mesh.

Thank you.

JanVogelsang commented 1 year ago

We fully support different mesh resolutions. Did you encounter any issues?

ShahramKa commented 1 year ago

The FDS case is ######## &HEAD CHID='PX-1-5000' /

&SLCF PBY=0.0,QUANTITY='VISIBILITY' / &SLCF PBY=0.0,QUANTITY='TEMPERATURE' / &SLCF PBY=0.0,QUANTITY='VELOCITY' / &SLCF PBY=0.0,QUANTITY='W-VELOCITY' / &DUMP DT_SLCF=0.5/

&TIME T_BEGIN=0.0,T_END=300.0 / &MISC TURBULENCE_MODEL='DYNAMIC SMAGORINSKY', SIMULATION_MODE='LES',FLUX_LIMITER='MINMOD' / &MATL ID = 'CONCRETE' SPECIFIC_HEAT = 1.20
DENSITY = 2000.0 EMISSIVITY = 0.9 CONDUCTIVITY = 1.2 /

&SURF ID = 'TUNNEL_WALL' MATL_ID = 'CONCRETE'
BACKING = 'INSULATED'
THICKNESS = 0.6
DEFAULT = .TRUE. /

&SURF ID = 'TUNNEL_WALLA' ADIABATIC = .TRUE. / MESH IJK=50,50,250, XB=-1.0,0.0,-1.0,0.0,0.0,5.0, MULT_ID='mesh' MULT ID='mesh', DX=1, DY=1, I_UPPER=1, J_UPPER=1/ MESH IJK=40,40,50,XB=-2.0,2.0,-2.0,2.0,0.0,5.0 / &MESH IJK=100,25,125, XB=-2.0,2.0,-2.0,-1.0,0.0,5.0 / &MESH IJK=100,25,125, XB=-2.0,2.0, 1.0, 2.0,0.0,5.0/ &MESH IJK=25,50,125, XB=-2.0,-1.0, -1.0, 1.0,0.0,5.0 / &MESH IJK=25,50,125, XB= 1.0,2.0, -1.0, 1.0,0.0,5.0/

&MESH IJK=50,50,250, XB=-1.0,0.0,-1.0,0.0,0.0,5.0/ &MESH IJK=50,50,250, XB= 0.0,1.0,-1.0,0.0,0.0,5.0/ &MESH IJK=50,50,250, XB=-1.0,0.0, 0.0,1.0,0.0,5.0/ &MESH IJK=50,50,250, XB= 0.0,1.0, 0.0,1.0,0.0,5.0/

&REAC FUEL = 'PROPANE' /

&SURF ID='FIRESURF',HRRPUA=750.0,RGB=255,0,0,RAMP_Q='RAMP_FIRE' /

&OBST XB=-0.1,0.1,-0.1,0.1,0.0,0.1,SURF_ID='TUNNEL_WALL',COLOR='BRICK' / base &VENT XB=-0.1,0.1,-0.1,0.1,0.1,0.1,SURF_ID='FIRESURF',COLOR='RED' /

&RAMP ID='RAMP_FIRE',T=0,F=0.0 / &RAMP ID='RAMP_FIRE',T=10.0,F=1.0 / &RAMP ID='RAMP_FIRE',T=60.0,F=1.0 / &RAMP ID='RAMP_FIRE',T=600.0,F=1.0 /

&VENT XB=-2.0,-2.0,-2.0,2.0,0.0,5.0,SURF_ID='OPEN' / &VENT XB=2.0,2.0,-2.0,2.0,0.0,5.0,SURF_ID='OPEN' / &VENT XB=-2.0,2.0,-2.0,-2.0,0.0,5.0,SURF_ID='OPEN' / &VENT XB=-2.0,2.0,2.0,2.0,0.0,5.0,SURF_ID='OPEN' / &VENT XB=-2.0,2.0,-2.0,2.0,5.0,5.0,SURF_ID='OPEN' /

&TAIL /

######## and reading slices gives me the following error. ####### slc_data = np.where(obstruction_mask[reduced_data_slices], slc_data, fill)

File <__array_function__ internals>:5 in where

ValueError: operands could not be broadcast together with shapes (308,26,1,126) (308,50,1,251) ()

JanVogelsang commented 1 year ago

The Python code snippet you provided does not yet indicate any error in the fdsreader, as you are simply trying to use numpy.where with arrays of different size. Please send your full script or explain why you think this error is caused by the fdsreader.

ShahramKa commented 1 year ago

Hi,

Thank you for your getting back to me. Just to clarify, the case is multi-mesh with a coarse mesh and a fine mesh (different mesh sizing). The error is at line 621 of the slice.py. To me, it is more related to how the arrays are deal with. Probably it should be interpolating to map the results to fine mesh in the 2D slice.

The script to use fdsreader is as follows.

import matplotlib.pyplot as plt import numpy as np import fdsreader as fds

sim = fds.Simulation("./PX-1-5000/PX-1-5000")

Get the first slice

slc = sim.slices[0]

data = slc.to_global()

data, coordinates = slc.to_global(masked=True, fill=np.nan, return_coordinates=True)

Plot the slice

plt.imshow(data[25].T, origin="lower") plt.colorbar() plt.show()

JanVogelsang commented 1 year ago

This should definitely work. Which version of the fdsreader are you using? And could you also send the FDS-case so I can reproduce the error locally?

ShahramKa commented 1 year ago

Thank you. The version is 1.9.9.

The fds case is

&HEAD CHID='PX-1-5000' /

&SLCF PBY=0.0,QUANTITY='VISIBILITY' / &SLCF PBY=0.0,QUANTITY='TEMPERATURE' / &SLCF PBY=0.0,QUANTITY='VELOCITY' / &SLCF PBY=0.0,QUANTITY='W-VELOCITY' / &DUMP DT_SLCF=0.5/

&TIME T_BEGIN=0.0,T_END=300.0 / &MISC TURBULENCE_MODEL='DYNAMIC SMAGORINSKY', SIMULATION_MODE='LES',FLUX_LIMITER='MINMOD' / &MATL ID = 'CONCRETE' SPECIFIC_HEAT = 1.20 DENSITY = 2000.0 EMISSIVITY = 0.9 CONDUCTIVITY = 1.2 /

&SURF ID = 'TUNNEL_WALL' MATL_ID = 'CONCRETE' BACKING = 'INSULATED' THICKNESS = 0.6 DEFAULT = .TRUE. /

&SURF ID = 'TUNNEL_WALLA' ADIABATIC = .TRUE. /

&MESH IJK=100,25,125, XB=-2.0,2.0,-2.0,-1.0,0.0,5.0 / &MESH IJK=100,25,125, XB=-2.0,2.0, 1.0, 2.0,0.0,5.0/ &MESH IJK=25,50,125, XB=-2.0,-1.0, -1.0, 1.0,0.0,5.0 / &MESH IJK=25,50,125, XB= 1.0,2.0, -1.0, 1.0,0.0,5.0/

&MESH IJK=50,50,250, XB=-1.0,0.0,-1.0,0.0,0.0,5.0/ &MESH IJK=50,50,250, XB= 0.0,1.0,-1.0,0.0,0.0,5.0/ &MESH IJK=50,50,250, XB=-1.0,0.0, 0.0,1.0,0.0,5.0/ &MESH IJK=50,50,250, XB= 0.0,1.0, 0.0,1.0,0.0,5.0/

&REAC FUEL = 'PROPANE' /

&SURF ID='FIRESURF',HRRPUA=750.0,RGB=255,0,0,RAMP_Q='RAMP_FIRE' /

&OBST XB=-0.1,0.1,-0.1,0.1,0.0,0.1,SURF_ID='TUNNEL_WALL',COLOR='BRICK' / base &VENT XB=-0.1,0.1,-0.1,0.1,0.1,0.1,SURF_ID='FIRESURF',COLOR='RED' /

&RAMP ID='RAMP_FIRE',T=0,F=0.0 / &RAMP ID='RAMP_FIRE',T=10.0,F=1.0 / &RAMP ID='RAMP_FIRE',T=60.0,F=1.0 / &RAMP ID='RAMP_FIRE',T=600.0,F=1.0 /

&VENT XB=-2.0,-2.0,-2.0,2.0,0.0,5.0,SURF_ID='OPEN' / &VENT XB=2.0,2.0,-2.0,2.0,0.0,5.0,SURF_ID='OPEN' / &VENT XB=-2.0,2.0,-2.0,-2.0,0.0,5.0,SURF_ID='OPEN' / &VENT XB=-2.0,2.0,2.0,2.0,0.0,5.0,SURF_ID='OPEN' / &VENT XB=-2.0,2.0,-2.0,2.0,5.0,5.0,SURF_ID='OPEN' /

&TAIL /

JanVogelsang commented 1 year ago

Which FDS Version are you using? With FDS 6.7.9 this gives me a segmentation fault on Ubuntu (while other simulation scripts do not).

JanVogelsang commented 1 year ago

@lu-kas This seems like a relatively simple error, could you look into this?

JanVogelsang commented 1 year ago

@ShahramKa I managed to get your case running on Windows 11 with FDS 6.8.0.0 and both the case and the fdsreader ran through successfully. All meshes were loaded in correctly, but indeed, I also get the error you observed.

JanVogelsang commented 1 year ago

Fixed in 1.9.10